标签:else sam while input stdio.h std cto secure 今天
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 690 Accepted Submission(s):
211
#define _CRT_SECURE_NO_DEPRECATE #include<iostream> #include<stdio.h> #include<algorithm> #include<queue> #include<set> #include<vector> #include<cstring> #include<string> #include<cmath> using namespace std; int year, month, day; bool judge(int year) {//判断闰年 if ((!(year % 4) && (year % 100)) || !(year % 400))return true; return false; } bool if_run = 0, if_hou = 0, special_judge = 0; int main() { int t; scanf("%d", &t); while (t--) { scanf("%d-%d-%d", &year, &month, &day); special_judge = 0; if (judge(year)) { if_run = true; if (month == 2 || month == 1)if_hou = false; else if_hou = true; if (month == 2 && day == 29)special_judge = 1; } else { if_run = false; if (month == 2 || month == 1)if_hou = false; else if_hou = true; } int sum = 0; while (1) { if (!special_judge) { if (if_run) { if (if_hou) { sum += 365 % 7; if (!(sum % 7))break; } else {//非后面月份 sum += 366 % 7; if (!(sum % 7))break; } } else {//非闰年 if (if_hou) { if (judge(year + 1)) { sum += 366 % 7; if (!(sum % 7))break; } else { sum += 365 % 7; if (!(sum % 7))break; } } else {//非后面月份 sum += 365 % 7; if (!(sum % 7))break; } } year++; if (judge(year))if_run = 1; else if_run = 0; } else {//特判 if (judge(year + 4)) { sum += (365 * 3 + 366) % 7; if (!(sum % 7))break; } else sum += (365 * 4) % 7; year += 4; } } if (special_judge) { year += 4; printf("%d\n", year); } else printf("%d\n", ++year); } return 0; }
标签:else sam while input stdio.h std cto secure 今天
原文地址:http://www.cnblogs.com/ZefengYao/p/7351353.html