五行山下的悟空

题目描述

《西游记》的故事可谓家喻户晓。孙悟空桀骜不驯，大闹天宫，搅得玉皇大帝不可终日，如来佛祖降服了悟空，将他压在五行山（又称五指山）下。如来的五指山其实叫做五行山，乃如来將五指化作金、木、水、火、土五座联山。悟空不知熬过了多少个寒冬酷暑、多少次斗转星移，其中的痛苦寂寞难以言状，漫长的岁月磨掉他的野性，练就他的面对困难的坚强意志。悟空清楚地记得，被压在五行山下的那天是某年某月某日，他通过询问过往的路人能得知今天是何年何月何日了，那么他已经被关押了多少天了了呢？悟空扳指计算，口中念念有词，一遍又一遍地倒手指。手指倒得发酸发软，嘴巴念得口干舌燥。这还不是最糟糕的，有时，一不小心倒错了手指或念错了数，只好重来，如此反复无数遍，费了很大的气力才算出了。不过，这样也好，正好打发了他那漫长无聊的时光。坚持就是胜利，最后，悟空等来了观音的搭救，辅佐唐僧去西天取经，终于修成正果。

样例输入

1 1 1
501 1 1

样例输出

182622
Monday
Saturday


提示

#include<iostream>
using namespace std;
bool check(int y)
{
if (y % 100 == 0)
{
if (y % 400 == 0)
return 1;
else
return 0;
}
else
{
if (y % 4 == 0)
return 1;
else
return 0;
}
}
int main()
{
int mon1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int mon2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
int y1, m1, d1;
int y2, m2, d2;
cin >> y1 >> m1 >> d1;
cin >> y2 >> m2 >> d2;
long long int sum = 0, count = 0;
if (check(y1) == false)
{
for (int i = 0; i < m1 - 1; i++)
sum -= mon1[i];
sum -= d1;
}
else
{
for (int i = 0; i < m1 - 1; i++)
sum -= mon2[i];
sum -= d1;
}
for (int i = y1; i < y2; i++)
{
if (check(i) == false)
sum += 365;
else
sum += 366;
}
if (check(y2) == false)
{
for (int i = 0; i < m2 - 1; i++)
sum += mon1[i];
}
else
{
for (int i = 0; i < m2 - 1; i++)
sum += mon2[i];
}
cout << sum + d2 + 1 << endl;
for (int i = 1; i < y1; i++)
{
if (check(i) == false)
count += 365;
else
count += 366;
}
if (check(y1) == false)
{
for (int i = 0; i < m1 - 1; i++)
count += mon1[i];
}
else
{
for (int i = 0; i < m1 - 1; i++)
count += mon2[i];
}
count += d1;
if (count % 7 == 1)
cout << "Monday" << endl;
else if (count % 7 == 2)
cout << "Tueday" << endl;
else if (count % 7 == 3)
cout << "Wednesday" << endl;
else if (count % 7 == 4)
cout << "Thursday" << endl;
else if (count % 7 == 5)
cout << "Friday" << endl;
else if (count % 7 == 6)
cout << "Saturday" << endl;
else
cout << "Sunday" << endl;
count += (sum + d2);
if (count % 7 == 1)
cout << "Monday" << endl;
else if (count % 7 == 2)
cout << "Tueday" << endl;
else if (count % 7 == 3)
cout << "Wednesday" << endl;
else if (count % 7 == 4)
cout << "Thursday" << endl;
else if (count % 7 == 5)
cout << "Friday" << endl;
else if (count % 7 == 6)
cout << "Saturday" << endl;
else
cout << "Sunday" << endl;
return 0;
}
/**************************************************************
Problem: 1711
User: 201730685257
Language: C++
Result: 正确
Time:0 ms
Memory:1484 kb
****************************************************************/