By: Fields
Knowledge Point: Analog + enumeration violence
Ideas: the title mentioned leap year
and many people believe that the leap is required to determine
in fact, contains a palindrome serial number of February 29, the top four is a leap year
then we can enumerate direct violence
Some small details:
1. The need to determine whether it exceeds 12 months
Date 2. Each month may differ
3. judgment does not require a leap year, February just need to see each year are 29 days to
4. The judgment of the month It must be 1000% / 100 to judge, or the same as in January and November, October is directly thrown away, the same as in February and December will happen (how I got 60 points). .
#include<iostream> #include<cstdio> #include<cstring> #include<sstream> using namespace std; int ans; stringstream ss; string s; int main() { int start,end; cin>>start>>end; for(int i=start;i<=end;i++) { if(i%10000/100>12) { continue; } if(i%10000/100==1||i%10000/100==3||i%10000/100==5||i%10000/100==7||i%10000/100==8||i%10000/100==10||i%10000/100==12) { if(i%100>31) { continue; } } if(i%10000/100==4||i%10000/100==6||i%10000/100==9||i%10000/100==11) { if(i%100>30) { continue; } } if(i%10000/100==2) { if(i%100>29) { continue; } } if(i%10000/100==0) { continue; } if(i%100==0) { continue; } int v=i; int fl=0; for(int j=1;j<=4;j++) { v/=10; } int x=v; int y=i%10000; int xx[5],yy[5]; xx[1]=x%10; xx[2]=x%100/10; xx[3]=x%1000/100; xx[4]=x%10000/1000; yy[1]=y%10000/1000; yy[2]=y%1000/100; yy[3]=y%100/10; yy[4]=y%10; for(int j=1;j<=4;j++) { if(xx[j]!=yy[j]) { fl=1; break; } } if(fl==0) { ans++; } } cost <<ans<<endl; return 0 ; }