题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
#include<bits/stdc++.h>
using namespace std;
unordered_map<string, int> months {{"January",1}, {"February", 2}, {"March", 3},
{"April",4}, {"May", 5}, {"June", 6},
{"July",7}, {"August", 8}, {"September", 9},
{"October",10}, {"November", 11}, {"December", 12}};
unordered_map<int, int> months_day {{1,31}, {2, 28}, {3, 31},
{4,30}, {5, 31}, {6, 30},
{7,31}, {8, 31}, {9, 30},
{10,31}, {11, 30}, {12, 31}};
unordered_map<int,string> week_day {{1,"Monday"},{2,"Tuesday"},{3,"Wednesday"},
{4,"Thursday"},{5,"Friday"},{6,"Saturday"},{0,"Sunday"},};
int main()
{
int day,year;
string month;
int y[3010],m[12];
y[0] = 0,m[0] = 0;
//初始化
for(int i = 1;i <= 3000;i ++)
if(((i % 4 == 0)&&(i % 100 != 0))||(i % 400 == 0))y[i] = y[i-1] + 366;
else y[i] = y[i-1] + 365;
for(int i = 1;i <= 12;i ++)
m[i] = m[i-1] + months_day[i];
while(cin >> day)
{
cin >> month >> year;
int day_nums = 0;
day_nums += y[year - 1] + m[months[month] - 1] + day;
if((((year % 4 == 0)&&(year % 100 != 0))||(year % 400 == 0))&&(months[month] > 2))day_nums += 1;
cout << week_day[day_nums % 7] << endl;
}
return 0;
}