蒟蒻第八个测试点WA求助
查看原帖
蒟蒻第八个测试点WA求助
1049413
QAQvQAQ楼主2024/2/24 19:50
#include<bits/stdc++.h>
using namespace std;
int summ=0,q,m,qwer;
int rn(int x){
	if((x%4==0 && x%100!=0) || x%400==0){
		return 1;
	}else{
		return 0;
	}
}
bool hw(int x){
	q=x%10000;
	m=x/10000;
	qwer=0;
	qwer+=q%10*1000;
	q/=10;
	qwer=qwer+q%10*100;
	q/=10;
	qwer=qwer+q%10*10;
	q/=10;
	qwer=qwer+q%10;
	if(qwer==m){
		return true;
	}
	return false;
}
int main(){
	int d1,d2;
	cin>>d1>>d2;
	for(int i=d1;i<=d2;i++){
		//查看是否合法
		//这个月有多少天 
		int month=i/100%100;
		//这是多少年
		int year=i/10000; 
		int t;
		if(month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12){
			t=31;
		}else if(month==2 && rn(year)==1){
			t=29;
		}else if(month==2 && rn(year)==0){
			t=28;
		}else{
			t=30;
		}
		if(i%100>t){
			i-=t;
			i+=100;
		}
		if(month==13){
			i-=1200;
			i+=10000;
		}
		if(hw(i)){
			summ++;
		}
	}
	cout<<summ<<endl;
    return 0;
}
/*
10140211
30160810

79
*/
2024/2/24 19:50
加载中...