首页 > 其他 > 详细

zoj 3785 What day is that day?

时间:2014-10-28 23:55:28      阅读:421      评论:0      收藏:0      [点我收藏+]

http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5272

打表找规律。

bubuko.com,布布扣
 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 }
View Code

 

zoj 3785 What day is that day?

原文:http://www.cnblogs.com/fanminghui/p/4058187.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!