Ren·Ashbell @ 2016-11-26 23:05:57
#include<iostream>
using namespace std;
int m,n,a[101],b[101]={1},c[101],d[101],v[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},cun[101];
int run(int year)
{
if(year%4==0&&year%100!=0)
return 1;
else
if(year%400==0)
return 1;
else
return 0;
}
int panhui(int year,int month,int date)
{ int bu=0,sum=0;
if(date<10)
{
cun[1]=date;
cun[2]=bu;
}
else
{
cun[1]=date%10;
date/=10;
cun[2]=date%10;
}
if(month<10)
{
cun[3]=month;
cun[4]=bu;
}
else
{
cun[3]=month%10;
month/=10;
cun[4]=month%10;
}
int sum_;
sum_=cun[1]*1000+cun[2]*100+cun[3]*10+cun[4];
if(sum_==year)
return 1;
else
return 0;
}
void dfs()
{
for(int i=1;i<=2;i++)
{
c[i]=m%10;
d[i]=n%10;
m/=10;
n/=10;
}
a[3]=c[1]+c[2]*10;
b[3]=d[1]+d[2]*10;
for(int i=1;i<=2;i++)
{
c[i]=m%10;
d[i]=n%10;
m/=10;
n/=10;
}
a[2]=c[1]+c[2]*10;
b[2]=d[1]+c[2]*10;
for(int i=1;i<=4;i++)
{
c[i]=m%10;
d[i]=n%10;
m/=10;
n/=10;
}
a[1]=c[1]+c[2]*10+c[3]*100+c[4]*1000;
b[1]=d[1]+d[2]*10+d[3]*100+c[4]*1000;
int sum=0;
if(run(a[1])==1)
v[2]=29;
if(a[1]==b[1]&&a[2]==b[2]&&a[3]==b[3])
{
if(panhui(a[1],a[2],a[3])==1)
sum++;
}
else
{
while(a[1]!=b[1]&&a[2]!=b[2]&&a[3]!=b[3])
if(a[2]<=12){
if(a[3]<=v[a[2]])
{
if(panhui(a[1],a[2],a[3])==1)
sum++;
a[3]++;
}
else
{
a[3]=1;
a[2]++;
}
}
else
{
a[2]=1;
a[1]++;
a[3]=1;
if(run(a[1])==1)
v[2]=29;
else
v[2]=28;
}
}
cout<<sum;
}
int main()
{
cin>>m>>n;
dfs();
}