1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#include <iostream>
//#include <stdfunc.hpp>
//#include <strfunc.hpp>
using namespace std;
static inline bool isLeapYear(int year)
{
return year%4==0 && (year%100!=0 || year%400==0);
}
int main()
{
int64_t secs=63379835348ll;
int year=1;
while (secs>=365*86400)secs-=(isLeapYear(year++)? 366 : 365)*86400;
static const int daysPerMonth[]={31,28,31,30,31,30,31,31,30,31,30,31};
int currentMonth=0;
while (secs>=daysPerMonth[currentMonth]*86400)
{
int days=daysPerMonth[currentMonth++];
if (currentMonth==2 && isLeapYear(year))days=29;
secs-=86400*days;
}
currentMonth++;
const int day=secs/86400+1;
secs%=86400;
const int hours=secs/3600;
secs%=3600;
const int minutes=secs/60;
secs%=60;
cout << year << "-" << leadingZeros(currentMonth,2) << "-" << leadingZeros(day,2) << " " << leadingZeros(hours,2) << ":" << leadingZeros(minutes,2) << ":" << leadingZeros(secs,2) << endl;
}
|