//蓝桥,高斯日记
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
int a[20] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int leap(int y)
{
if(y%400 == 0 || (y%4==0 && y%100!=0))
return 1;
return 0;
}
int main()
{
int y,m,d;
const int Y = 1777,M = 4,D = 30;
int day;
while(cin>>day){
for(m = 5;m<=12;m++)
day-=a[m];
y = Y+1;
while(day>365)
{
if(leap(y))
day-=366;
else
day-=365;
y++;
}
if(leap(y))
a[2]++;
for(m = 1;m<=12;m++)
{
if(day<a[m])
break;
day-=a[m];
}
cout << y << "-" << m << "-" << day-1 << endl;
}
return 0;
}
时间: 2024-10-29 21:20:49