60分,向大神求助(NOIP七十分)

P2010 [NOIP2016 普及组] 回文日期

引领世界 @ 2016-12-25 10:12:26

#include <cstdio>
int ans;
bool hw(int n){
    int b=0,c=n;
    for (;n!=0;n/=10)b=b*10+n%10;
    if (b==c)return true;
    return false;
}
int main(void){
    int date2,j=0,i,m[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    scanf ("%d\n%d",&i,&date2);
    for (;i<=date2;i++){
        m[1]+=i/10000%400==0||i/10000%100&&i/10000%4==0;
        if (i%100>m[j])j++,i=(i/100+j+1)*100+1;
        if (j>11)j=0;
        if (hw(i))ans++;
    }
    printf ("%d",ans);
}

|