ZOJ3785-What day is that day?
来源:互联网 发布:js给集合添加元素 编辑:程序博客网 时间:2024/06/06 16:25
It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days?
Input
There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:
There is only one line containing one integer N (1 <= N <= 1000000000).
Output
For each test case, output one string indicating the day of week.
Sample Input
212
Sample Output
SundayThursday
Hint
A week consists of Sunday, Monday, Tuesday, Wednesday, Thursday, Friday and Saturday.
Author: ZHOU, Yuchen
Source: The 11th Zhejiang Provincial Collegiate Programming Contest
题意:给你一个n,今天星期六,问11 + 22 + 33 + ... + NN 天后是星期几
解题思路:打表后找到循环节
#include <iostream>#include <cstdio>#include <algorithm>#include <cmath>#include <cstring>#include <string>#include <map>#include <vector>#include <queue>#include <bitset>#include <stack>using namespace std;int a[1005];int qpow(int x,int y){ int sum=1; while(y) { if(y&1) sum*=x,sum%=7; y>>=1; x*=x; x%=7; } return sum;}int main(){ a[1]=1; for(int i=2;i<=400;i++) { int k=i%7; int ans=qpow(k,i); a[i]=ans+a[i-1]; a[i]%=7; } a[0]=a[294]; int n,t; scanf("%d",&t); while(t--) { scanf("%d",&n); n%=294; if(a[n]==0) printf("Saturday\n"); else if(a[n]==1) printf("Sunday\n"); else if(a[n]==2) printf("Monday\n"); else if(a[n]==3) printf("Tuesday\n"); else if(a[n]==4) printf("Wednesday\n"); else if(a[n]==5) printf("Thursday\n"); else if(a[n]==6) printf("Friday\n"); } return 0;}
0 0
- ZOJ3785:What day is that day?
- zoj3785 What day is that day?
- ZOJ3785-What day is that day?
- ZOJ3785 What day is that day?(找循环节)
- ZOJ3785 What day is that day?(同余与模算术)
- What day is that day?
- What day is that day?
- What day is that day?
- What day is that day? --数学
- zoj 3785 What day is that day?
- ZOJ-3785【What day is that day?】
- zoj-What day is that day?
- zoj 3785 What day is that day?
- ZOJ 3785 What day is that day?
- J.What day is that day?
- ZOJ 3785 What day is that day?
- ZOJ 3785 What day is that day?
- Zoj 3785 What day is that day?
- Redis实现高并发下的抢购、秒杀功能
- 素数打表(小模板)
- 【ES6】16.generator函数的语法 10.(1)异步操作的同步化表达
- 3天速成混合app开发_01环境部署
- 排序算法
- ZOJ3785-What day is that day?
- EventBus使用详解
- matlab kmeans 代码
- Node.js安装及环境配置之Windows篇
- .gitignore 的使用
- Hexo搭建github博客绑定顶级域名和www子域名
- JAVA OOP 第四章 接口
- Linux下安装mysql
- Linux c 贪吃蛇 无curses、多线程、信号的实现