码迷,mamicode.com
首页 > 其他好文 > 详细

zoj 3785 What day is that day?

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

标签:style   blog   http   io   color   os   ar   for   sp   

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?

标签:style   blog   http   io   color   os   ar   for   sp   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!