#include<cstdio> #include<iostream> #include<string> #include<map> using namespace std; int main() { int m; cin>>m; int year,mon,day,sum; int mday[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; while(m--) { int totalday=0; scanf("%d%d%d%d",&year,&mon,&day,&sum); for(int i=0;i<sum;i++) { if(year%400==0||year%4==0&&year%100!=0){ mday[2]=29; } else { mday[2]=28; } totalday++; day++; if(day>mday[mon]) { day=1; ++mon; if(mon>12){ day=1; mon=1; year++; } } if(totalday==sum) { break; } } printf("%04d-%02d-%02d\n",year,mon,day); } }
依旧是nextday策略