求分析

P2010 [NOIP2016 普及组] 回文日期

d3NtMDAw @ 2017-09-02 13:23:51

#include<iostream>
#include<stdlib.h>
using namespace std;
int main()
{
    int ans=0;
    int d1,d2;
    cin>>d1>>d2;
    int y1,y2;
    int e1,e2;
    y1=d1/10000;
    e1=d1%10000;
    e2=d2%10000;
    y2=d2/10000;
    int i,j,k,a2,a1,a3,a4,a;
    for(i=y1;i<=y2;i++)
    {
     k=i;
     a4=k%10;
     k=k/10;
     a3=k%10;
     k=k/10;
     a2=k%10;
     k=k/10;
     a1=k;
     a=a1+a2*10+a3*100+a4*1000;    
     if((a3==0&&a4==0)||a4>1)
       continue;
     if(a4==1&&a3>=3)
       continue;
     if(a2>3)
       continue;
     if(a2==3&&a1>1) 
       continue;
     if(a3<7&&a3%2==0&&a1>0&&a2==3) 
       continue;
     if((a3==11||a3==9)&&a1>0&&a2==3) 
       continue; 
     if(i==y1&&a<e1)
       continue;
     if(i==y2&&a>e2)
       continue;
     ans++;          
    }
    cout<<ans<<endl;
    //system("pause"); 
    return 0; 
}

|