ZOJ 3785-What day is that day 解题报告
2014-04-15 21:24
453 查看
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5272
主要是找到一个规律,比赛的时候想到了可能是找规律,但找的数太小了,只找了20以内的,其实是294,找到了规律就简单了,打个表就行,这里用到了快速幂,只要logn的时间。
#include <cstdio> #include <algorithm> using namespace std; const char week[7][20]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"}; int q_mi(int num,int n){ int ans=1; while(n!=0){ if(n&1) ans=(ans*num)%7; n>>=1; num=(num*num)%7; } return ans; } int main(){ int i,j; int T; scanf("%d",&T); int table[300]; table[0]=0; for(i=1;i<=294;i++){ table[i]=(table[i-1]+q_mi(i,i))%7; } while(T--){ int n; scanf("%d",&n); n%=294; printf("%s\n",week[table ]); } return 0; }
相关文章推荐
- ZOJ 3785 What day is that day?
- zoj-3785-What day is that day?
- ZOJ 3785 What day is that day?(费马小定理智寻循环节)
- ZOJ3785-What day is that day?
- What day is that day? ZOJ - 3785
- zoj 3785 What day is that day?(找规律,KMP)
- ZOJ-3785【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? —— 打表
- ZOJ 3785 11th省赛 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?
- zoj 3785 What day is that day?
- ZOJ 3785 - What day is that day?
- ZOJ 3785 What day is that today? (费马小定理)
- ZOJ 3785 What day is that day?(打表找周期)
- ZOJ 3785 What day is that day?【思维+递推循环节】
- zoj 3785 What day is that day?