#include <iostream> using namespace std; bool check_year(int year){ if((year%4==0&&year%100!=0)||year%400==0)return true; return false; } int main() { int T; int year,month,day,n; int count[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}}; cin>>T; while (T--) { // 注意 while 处理多个 case cin>>year>>month>>day>>n; n+=day; while(n){ if(month==2&&check_year(year))n-=29; else n-=count[0][month]; if(n<=0){ if(month==2&&check_year(year))n+=29; else n+=count[0][month]; break; } month++; if(month>12){ month=month%12; year+=1; } } printf("%04d-%02d-%02d\n",year,month,n); } } // 64 位输出请用 printf("%lld")