文章

6

粉丝

375

获赞

3

访问

49.4k

头像
暴力推算
P1287 上海交通大学机试题
发布于2021年3月17日 22:43
阅读数 7.7k

不考虑儒略历推算,公元1年1月1日是星期一

#include <bits/stdc++.h>
using namespace std;
int n;
int xq[5000][20][50];
int isLeap(int y){
    if(y%4==0&&y%100!=0||y%400==0)return 1;
    else return 0;
}
int m2d[5][20]={{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int y2d[5]={365,366};
string dayName[10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
string monthName[20]={"","January","February","March","April","May","June","July","August","September","October","November","December"};
int main(){
	int d,m,y;
	string mn;
	int cnt=0;
	for(int y=1;y<=2100;++y){
	    int l=isLeap(y);
        for(int m=1;m<=12;++m){
            for(int d=1;d<=m2d[l][m];++d){
                cnt++;
                xq[y][m][d]=cnt%7;
            }
        }
	}
	unordered_map<string,int>mn2m;
	for(int i=1;i<=12;++i){
        mn2m[monthName[i]]=i;
	}
	while(cin>>d>>mn>>y){
        m=m...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发