64分!!!紧急求助

P2010 [NOIP2016 普及组] 回文日期

包包 @ 2021-07-15 21:17:01


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
int s[50]={31,28,31,30,31,30,31,31,30,31,30,31};
long long a,b,t,h,c,sum;
using namespace std;
long long huiwen(int a1)
{
    int k=0;
    while(a1!=0)
    {
        k=k*10+a1%10;
        a1/=10;
    }
    return k;
}
int main()
{
    //freopen("date.in","r",stdin);
    //freopen("date.out","w",stdout); 
    cin>>a>>b;
    h=a/10000000*1000+a/1000000%10*100+a/100000%10*10+a/10000%10;
    t=b/10000000*1000+b/1000000%10*100+b/100000%10*10+b/10000%10;
    for(int i=h;i<=t;i++)
    {
        for(int j=1;j<=12;j++)
        {
            for(int k=1;k<=s[j-1];k++)
            { 
                c=i*10000+j*100+k;
                if(huiwen(c)==c) sum++;
            }
        }
    }
    cout<<sum;
    //fclose(stdin);
    //fclose(stdout);
    return 0;
}

by Mathlover__CQYZ @ 2021-08-21 11:16:08

我也是蒟蒻 这能得90分


#include<bits/stdc++.h>
long long n,m,a,p;
int yue[13]={31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
    scanf("%d %d",&n,&m);
    for(int i=1;i<=12;i++)
        for(int j=1;j<=yue[i-1];j++)
        {
            a=(j%10)*1000+(j/10)*100+(i%10)*10+i/10;
            if(a<(n/10000)||a>(m/10000))continue;
            p++;
        }
    if(n<=92200229&&m>=92200229)p++;
    printf("%d",p);
}

|