I ask Ho XI
Time limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 568 accepted Submission (s): 168
Problem Description
Today is August 6, 2017, the lunar calendar June 15. Small degree alone railing, looking at a round moon, issued a "I ask Xi, see this Lover" lonely feeling. To divert the knot, it decided to think about a mathematical problem: the same day of the next recent year, and the number of weeks today. For example, today is August 6, Sunday. The next is also Sunday, August 6, which took place in 2023. Tip: In the Gregorian calendar, a leap year can be divisible by 4 but not divisible by 100, or divisible by 400.
Input
The first behavior, T, represents the number of input data sets. Each group of data contains a date, formatted as YYYY-MM-DD. 1≤t≤10000 yyyy≥2017 Date must be a valid date Output
For each set of data output answer year, the title guarantee that the answer will not exceed four digits.
Sample Input
3
2017-08-06
2017-08-07
2018-01-01
Sample Output
2023
2023
2024
#include <queue> #include <map> #include <vector> #include <cmath> #include <stack> #
Include <climits> #include <string> #include <cstring> #include <algorithm> using namespace std;
int t[10003][13][35];
int yue[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main () {int num = 1;
int year = 1,m = 1,n = 1;
memset (t,-1,sizeof (T)); while (!) (
Year = = 10000 && m = = 1 && n = 1)) {if (year%4==0 && year%100!=0 | |-year%400 = 0)
YUE[2] = 29;
else yue[2] = 28;
T[year][m][n] = num++;
Int j = N/yue[m];
n++;
if (j) {n = 1;
j = (m)/12;
m++;
if (j) m = 1;
Year + + J;
} int t;
scanf ("%d", &t);
while (t--) {scanf ("%d-%d-%d", &year,&m,&n);
int be = T[year][m][n]; for (int i = Year+1;i < 10000; i++) {if (T[i][m][n]!=-1 && (t[i][m][n]-be)% 7 = 0) {printf (
"%d\n", I);
Break
}} return 0;
}