Dalao求指错

P2010 [NOIP2016 普及组] 回文日期

pointedpoints @ 2016-12-17 17:34:39

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<cmath>
#include<queue>
using namespace std;
int ans,year1,year2,month1,month2,date1,date2,monthh1,datee1,ss1,ss2,s1,s2;
int datess[2][13]=
    {{31,28,31,30,31,30,31,31,30,31,30,31},
    {31,29,31,30,31,30,31,31,30,31,30,31}};
bool check(int yy)
    {if(ss1>s2||ss1<s1)return 0;
    if(monthh1==0||monthh1>12)return 0;
    if(datee1==0)return 0;
    if((yy%4==0&&yy%100!=0)||yy%400==0)
        {if(datee1>datess[1][monthh1])return 0;}
    else if(datee1>datess[0][monthh1])return 0;
    return 1;
    }
void solve()
    {int i;
    scanf("%d%d",&s1,&s2);
    year1=s1/10000;
    year2=s2/10000;
    month1=s1%10000/100;
    month2=s2%10000/100;
    date1=s1%100;
    date2=s2%100;
    for(i=year1;i<=year2;i++)
        {ss1=i*10000+i%10*1000+i%100/10*100+i%1000/100*10+i%10000/1000;
        monthh1=ss1%10000/100;datee1=ss1%100;
        if(check(i))ans++;
        }
    }
int main(){
    solve();
    printf("%d",ans);
    return 0;
}

|