求助,64,还有个TLE

P2010 [NOIP2016 普及组] 回文日期

ydnaC_oCoC @ 2020-11-05 13:35:53

#include<iostream>
using namespace std;
int P(int n)
{
    int n1,m1;
    n1=n/10000;
    n-=n1*10000;
    m1=n/1000+n%1000/100*10+n%100/10*100+n%10*1000;
    if(n1==m1) return 1;
    else return 0;
}
int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    for(int i=n;i<=m;i++)
    {
        if(P(i)==1) ans++;
    }
    cout<<ans;
}

|