求助!

P2010 [NOIP2016 普及组] 回文日期

Ticzone @ 2018-11-06 20:04:17

为什么六十分?

code:

#define lal long long int
#define F(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
lal i,j,k,n;
char da[9],db[9];
lal a[9],b[9];
lal c[9];
lal x,y;
lal count_;
lal mon[13]={233,30,28,31,30,31,30,31,31,30,31,30,31};
lal mor[13]={233,30,29,31,30,31,30,31,31,30,31,30,31};
bool bax()
{
    if(da[0]==da[7])
        if(da[1]==da[6])
            if(da[2]==da[5])
                if(da[3]==da[4])
                    return 1;
    return 0;
}
bool bxa()
{
    if(c[0]==c[7])
        if(c[1]==c[6])
            if(c[2]==c[5])
                if(c[3]==c[4])
                    return 1;
    return 0;
}
bool pd(bool dp,lal xy)
{
    if(!dp)
    {
        lal sun=c[1]*10+c[0];
        lal w=xy;
        w%=10000;
        w/=100;
        if(w>=13 || w<1)
            return 0;
        if(sun>mor[w] || sun==0)
            return 0;
        return 1;
    }
    if(dp)
    {
        lal sun=c[1]*10+c[0];
        lal w=xy;
        w%=10000;
        w/=100;
        if(w>=13 || w<1)
            return 0;
        if(sun>mon[w] || sun==0)
            return 0;
        return 1;
    }
}
int main()
{
    //F(date);
    gets(da);
    gets(db);
    if(!strcmp(da,db))
    {
        if(bax())
        {
            printf("1");
            return 0;
        }
        else
        {
            printf("0");
            return 0;
        }
    }
    for(i=0;i<8;i++)
    {
        a[i]=da[i]-'0';
        x*=10;
        x+=a[i];
        b[i]=db[i]-'0';
        y*=10;
        y+=b[i];
    }
    for(i=x;i<=y;i++)
    {
        lal d=i;
        c[0]=d/1%10;
        c[1]=d/10%10;
        c[2]=d/100%10;
        c[3]=d/1000%10;
        c[4]=d/10000%10;
        c[5]=d/100000%10;
        c[6]=d/1000000%10;
        c[7]=d/10000000%10;//强迫症的悲哀 QAQ
        if(i/1000%4==0 && i/1000%100!=0)
        {
            if(pd(0,i))
                if(bxa)
                    count_++;
        }
        else if(i/1000%400==0)
        {
            if(pd(0,i))
                if(bxa)
                    count_++;
        }
        else
        {
            if(pd(1,i))
                if(bxa)
                    count_++;
        }
    }
    return 0;
}

评测记录


by Kevin_Wa @ 2018-11-06 20:26:51

表示没看懂


by YU401 @ 2018-11-06 21:30:37

特判了吗


|