首页 > 代码库 > zoj 3785 What day is that day?
zoj 3785 What day is that day?
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5272
打表找规律。
1 #include <cstdio> 2 #include <cstring> 3 #include <algorithm> 4 #define LL long long 5 using namespace std; 6 const int mod=7; 7 char g[][10]={"Saturday","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday"}; 8 int a[300]; 9 10 LL pow_m(LL a,LL n)11 {12 LL ret=1;13 LL temp=a%mod;14 while(n)15 {16 if(n&1) ret=(ret*temp)%mod;17 temp=temp*temp%mod;18 n>>=1;19 }20 return ret;21 }22 23 int deal(int n)24 {25 int ans=1;26 for(int i=1; i<=n; i++)27 {28 ans*=n;29 ans%=mod;30 }31 return ans;32 }33 34 int main()35 {36 int t;37 scanf("%d",&t);38 a[0]=0;39 for(int i=1; i<=294; i++)40 {41 a[i]=a[i-1]+deal(i);42 a[i]%=mod;43 }44 while(t--)45 {46 int n;47 scanf("%d",&n);48 int ans=a[(n%294)];49 printf("%s\n",g[ans]);50 }51 return 0;52 }
zoj 3785 What day is that day?
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。