01234567899870z @ 2017-11-04 19:43:08
QUICKLY
by Zhao001 @ 2017-11-04 19:47:15
自己理解#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdio>
using namespace std;
int s[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int main()
{
// freopen("date.in","r",stdin);
// freopen("date.out","w",stdout);
int m,n,k=0,a=0,b=0;
scanf("%d %d",&m,&n);
if(m==n)
{
char x[10];
int k=0;
sprintf(x,"%d",m);
for(int i=0;i<4;i++)
{
if(x[i]==x[7-i])
k++;
}
if(k==4)
cout<<'1';
else
cout<<'0';
return 0;
}
for(int i=1;i<=12;i++)
{
for(int j=1;j<=s[i];j++)
{
a=(j%10)*1000+(j/10)*100+(i%10)*10+(i/10);
b=a*10000+i*100+j;
if(b>=m&&b<=n)
k++;
}
}
cout<<k;
return 0;
}
by Zhao001 @ 2017-11-04 19:48:19
源自一位大牛的思路
by wenzhang @ 2017-12-10 17:38:57
#include<bits/stdc++.h>
using namespace std;
int hw(int x) {
int y=0;
while(x) {
y=y*10+x%10;
x/=10;
}
return y;
}
int pd(int a) {
int r=a%100,y=a/100;
if(y<=0||y>12||r<=0||r>31)return 0;
if(y==4||y==6||y==9||y==11&&r>30)return 0;
if(y==2&&r>29)return 0;
return 1;
}
int i,a,b,n,m,ans,a1,b1;
int main() {
scanf("%d%d",&a,&b);
n=a/10000;
m=b/10000;
a1=a%10000;
b1=b%10000;
if(hw(n)>=a1&&pd(hw(n)))ans++;
if(hw(m)<=b1&&pd(hw(m))&&n!=m)ans++;
for(i=n+1; i<m; i++)
if(pd(hw(i)))ans++;
printf("%d\n",ans);
return 0;
}70
by wenzhang @ 2017-12-10 17:39:30
??