hackWA 求助
查看原帖
hackWA 求助
726902
bcbgszyzh楼主2024/10/25 08:41
#include<bits/stdc++.h>
using namespace std;
int DayNum[]={-1,31,28,31,30,31,30,31,31,30,31,30,31};
bool p(int x){
	if( x%4==0 && x%100!=0|| x%400==0 ) 
        return true;
    else
        return false;
}
int main(){
	int a,b;
	cin>>a>>b;
	int cnt=0;
	for(int i=a/10000;i<=b/10000;++i) {
		if(p(i))DayNum[2]++;
		int x=(i%10)*10+i/10%10,y=(i/100%10)*10+i/1000;
		if(x>=1&&x<=12){
			if(y>=1&&y<=DayNum[x]){
				cnt++;
			}
		}
		if(p(i))DayNum[2]--;
	}
	printf("%d",cnt);
	return 0;
}
2024/10/25 08:41
加载中...