李恩泽 @ 2017-11-08 21:28:49
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
char a[9],b[9];
int d11,d12,d13,d21,d22,d23,n1,n2,m[13]={-1,31,28,31,30,31,30,31,31,30,31,30,31},h1,h2,ans=0;
int main()
{
cin>>a>>b;
d11=(a[0]-48)*1000+(a[1]-48)*100+(a[2]-48)*10+(a[3]-48)*1;
d12=(a[4]-48)*10+(a[5]-48)*1;
d13=(a[6]-48)*10+(a[7]-48)*1;
d21=(b[0]-48)*1000+(b[1]-48)*100+(b[2]-48)*10+(b[3]-48)*1;
d22=(b[4]-48)*10+(b[5]-48)*1;
d23=(b[6]-48)*10+(b[7]-48)*1;
n1=d11;
n2=d21;
for(int i=n1;i<=n2;i++)
{
for(int k=1;k<=12;k++)
{
if((k%4==0&&k%100!=0)||k%400==0)
{
m[2]=29;
}
if(i==n1&&k<d12)
{
continue;
}
for(int t=1;t<=m[k];t++)
{
if(i==n1&&k==d12&&t<d13)
{
continue;
}
h1=(i%10)*1000+(i/10%10)*100+(i/100%10)*10+(i/1000%10)*1;
h2=k*100+t;
if(h1==h2)
{
ans++;
}
}
}
}
printf("%d\n",ans);
return 0;
}
by Altria_Pendragon_ @ 2017-11-08 22:21:54
var
s1,s2:string;
tmp,s,i,t:longint;
function max(year,month:longint):longint;
begin
case month of
1,3,5,7,8,10,12:exit(31);
4,6,9,11:exit(30);
2:exit(29);
end;
end;
function check(year:longint):longint;
var
i,month,day,m,d,m1,d1:longint;
begin
month:=year mod 10*10+year div 10 mod 10;
day:=year mod 1000 div 100*10+year div 1000;
if (month<=12) and (day<=max(year,month)) and (month>0) and (day>0)
then exit(1) else exit(0);
end;
begin
readln(s1);
readln(s2);
{tmp:=1;
s:=0;
for i:=1 to 4 do
if s1[i]<>s1[9-i] then begin tmp:=0; break; end;
inc(s,tmp);
if s1<>s2 then
begin
tmp:=1;
for i:=1 to 4 do
if s2[i]<>s2[9-i] then begin tmp:=0; break; end;
inc(s,tmp);}
s:=0;
val(copy(s1,1,4),tmp);
val(copy(s2,1,4),t);
for i:=tmp{+1} to t{-1} do
inc(s,check(i));
//end;
writeln(s);
end.