nyoj An problem about date(吉姆拉尔森公式)

求星期几。。公式题放在DP里面,无语。。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cstdlib>
 4 #include<cstring>
 5 #include<string>
 6 #include<queue>
 7 #include<algorithm>
 8 #include<map>
 9 #include<iomanip>
10 #include<climits>
11 #include<string.h>
12 #include<cmath>
13 #include<stdlib.h>
14 #include<vector>
15 #include<stack>
16 #include<set>
17 #define INF 1e7
18 #define MAXN 100010
19 #define maxn 1000010
20 #define Mod 1000007
21 #define N 1010
22 using namespace std;
23 typedef long long LL;
24 
25 int y, m, d;
26 
27 void run()
28 {
29     if (m == 1 || m == 2) {
30         m += 12;
31         y--;
32     }
33     int ans = ((d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) + 1) % 7;
34     printf("%d
",ans);
35 }
36 
37 int main()
38 {
39     while (~scanf("%d%d%d",&y,&m,&d))
40         run();
41     //system("pause");
42     return 0;
43 }
原文地址:https://www.cnblogs.com/usedrosee/p/4356859.html