1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #include <iostream> #include <algorithm> #include <stdio.h> #include <string> #include <cstring> #include <math.h> using namespace std; double eps = 1e-8;
int getday(int d, int m, int y){ if(m == 1 || m == 2) m += 12, --y; return (d + 2*m + 3*(m+1)/5 + y%7 + y/4%7 - y/100%7 + y/400%7) % 7 + 1; }
int calculate() { int cnt = 0; for(int i = 2004; i <= 2403; ++i) { for(int j = 1; j <= 12; ++j) { if(getday(1,j,i) == 1)cnt++; if(getday(11,j,i) == 1) cnt++; if(getday(21,j,i) == 1) cnt++; } } cout << cnt << '\n'; } int main() { int n, y1,m1 ,d1,t; scanf("%d",&t); while(t--) { scanf("%d %d %d %d",&y1,&m1,&d1,&n); long long yy1 = n / 2058 * 400; n = n % 2058; if(n == 0) n = 2058; int cnt = 0; while(1) { if(getday(d1,m1,y1) == 1) cnt++; if(cnt == n ) break; d1 = d1 + 10; if(d1 == 31) { m1++; d1 = 1; if(m1 > 12) { m1 = 1; y1++; } } } printf("%lld %d %d\n", (y1 + yy1), m1, d1); } }
|