文章

6

粉丝

375

获赞

3

访问

49.4k

头像
暴力推算
P1290 上海交通大学/西北工业大学2019机试
发布于2021年3月17日 22:47
阅读数 8.0k

#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 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;
            }
        }
	}
	string date1,date2;
	while(cin>>date1>>date2){
        int y1=stoi(date1.substr(0,4)),y2=stoi(date2.substr(0,4)),
            m1=stoi(date1.substr(4,2)),m2=stoi(date2.substr(4,2)),
     ...
登录查看完整内容


登录后发布评论

暂无评论,来抢沙发