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
",g[ans]);
50     }
51     return 0;
52 }
View Code
原文地址:https://www.cnblogs.com/fanminghui/p/4058187.html