题目链接:http://nyoj.top/problem/1363
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS cin.tie(0); cout.tie(0); ios::sync_with_stdio(0);
const int inf = 0x3f3f3f3f;
const int N = 3e5+7;
int date[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
IOS; int t; cin >> t;
while(t--)
{
string str; cin >> str;
int n, k; cin >> k >> n;
int year = atoi(str.substr(0, 4).c_str());
int month = atoi(str.substr(4, 2).c_str());
int day = atoi(str.substr(6, 2).c_str());
int week = (n - 7 + k) % 7;
while(n--)
{
if(year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
date[2] = 29;
else date[2] = 28;
day++;
if(day > date[month])
day = 1, month++;
if(month > 12)
year++, month = 1;
}
printf("%d%02d%02d %d\n",year,month,day,week);
}
}