1 #include <bits/stdc++.h> 2 using namespace std; 3 bool Check(int y){return (y%4==0&&y%100)||(y%400==0);} 4 void calc(int Y,int M,int D,int x){ 5 int y=Y,m=M,d=D; 6 for(int i=1;i<x;i++){ 7 d++; 8 if(m==12&&d==32){m=1,d=1,y++;continue;} 9 if((m==1||m==3||m==5||m==7||m==8||m==10)&&d==32){m++,d=1;continue;} 10 if((m==4||m==6||m==9||m==11)&&d==31){m++,d=1;continue;} 11 if((m==2)&&Check(y)&&d==30){m++,d=1;continue;} 12 if((m==2)&&!Check(y)&&d==29){m++,d=1;continue;} 13 } 14 cout<<y<<" "<<m<<" "<<d<<endl; 15 } 16 int main(){ 17 calc(1777,4,30,5343);//1791 12 15 18 calc(1777,4,30,8113);//1799 7 16 19 return 0; 20 }