#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
double g2jd(int year, int month, int day)
{
int t;
double jd;
if (month < 3) {
year--;
month += 12;
}
t = year / 100;
jd = (int)(year * 365.25) - t + t / 4;
jd += (int)(30.6001 * (month + 1)) + day + 1720996.5;
return jd;
}
void jd2g(double jd, int *pyear, int *pmonth, int *pday)
{
int z, aa, a, b, c, k, e;
jd += 0.5;
z = (int)jd;
aa = (int)((z - 1867216.25) / 36524.25);
a = (int)(z + 1 + aa - aa / 4);
b = a + 1524;
c = (int)((b - 122.1) / 365.25);
k = (int)(365.25 * c);
e = (int)((b - k) / 30.6001);
*pday = b - k - (int)(30.6001 * e);
*pmonth = (e <= 13) ? e - 1 : e - 13;
*pyear = (*pmonth > 2) ? c - 4716 : c - 4715;
}
int main()
{
char buf[256];
int year, month, day, days;
double jd;
if (fgets(buf
, sizeof buf
, stdin
) == NULL
) { return 1;
}
if (sscanf(buf
, "%4d%2d%2d %d", &year
, &month
, &day
, &days
) != 4) { return 1;
}
printf("%d %d %d %d\n", year
, month
, day
, days
);
jd = g2jd(year, month, day);
jd += days;
jd2g(jd, &year, &month, &day);
printf("%d/%d/%d %.2s\n", year
, month
, day
, "SuMoTuWeThFrSa" + (((int)jd
+ 2) % 7) * 2);
return 0;
}
I2RlZmluZSBfQ1JUX1NFQ1VSRV9OT19XQVJOSU5HUwojaW5jbHVkZSA8c3RkaW8uaD4KCmRvdWJsZSBnMmpkKGludCB5ZWFyLCBpbnQgbW9udGgsIGludCBkYXkpCnsKCWludCB0OwoJZG91YmxlIGpkOwoKCWlmIChtb250aCA8IDMpIHsKCQl5ZWFyLS07CgkJbW9udGggKz0gMTI7Cgl9Cgl0ID0geWVhciAvIDEwMDsKCWpkID0gKGludCkoeWVhciAqIDM2NS4yNSkgLSB0ICsgdCAvIDQ7CglqZCArPSAoaW50KSgzMC42MDAxICogKG1vbnRoICsgMSkpICsgZGF5ICsgMTcyMDk5Ni41OwoJcmV0dXJuIGpkOwp9Cgp2b2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