ACM-ICPC 2019 山东省省赛 A Calandar
这个题,呃完全的送分题,签到题,一周只有五天,一年12个月,一个月30天,公式为((year1-year2)*360%5+(month1-month2)*30%5+day1-day2+初始星期)%5,但是360%5=0,30%5=0,只用看天数。
上题解:
#include <cstdio>
#include<math.h>
#include<iostream>
#include<map>
using namespace std;
int main()
{
int t;
long long laji;
int day1,day2;
string ob;
map<string,int > flag;
flag.insert(make_pair("Monday",0));
flag.insert(make_pair("Tuesday",1));
flag.insert(make_pair("Thurday",3));
flag.insert(make_pair("Wednesday",2));//分不清周几是周几;
flag.insert(make_pair("Friday",4));
cin>>t;
while(t--)
{
cin>>laji>>laji>>day1;
cin>>ob;
cin>>laji>>laji>>day2;
int tem=(day2+30-day1+flag[ob])%5;
if(tem==0) cout<<"Monday"<<endl;
if(tem==1) cout<<"Tuesday"<<endl;
if(tem==3) cout<<"Thurday"<<endl;//分不清周几是周几;
if(tem==2) cout<<"Wednesday"<<endl;
if(tem==4) cout<<"Friday"<<endl;
}
}