杭电oj2089

#include<iostream>
#include<cstdio>
using namespace std;
#define ll long long


int main(void)
{
ll a,b,c,t,e;
int f,k,l,m;
while(cin>>a>>b&&(a||b)){
c = b-a+1;
f = 0;
for(int i = a;i<=b;++i){
f = m = 0;
t = e = i;
while(t>0){
f = t%10;
t /= 10;
if(f == 4)
break;
}
if(f == 4){
c -= 1;
break;
}
while(e>10){
k = e%10;
l = e%100/10;
if(l == 6&&k == 2){
m = 1;
break;
}
e = e/10;
}
if(m == 1){
c -= 1;
break;
}
}
cout<<c<<endl;
}

return 0;}

//以上带码时间会超过

//下面代码才ok

#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define ll long long
int m[1000001]={0};
void p(){

int t;
for( int i = 1;i<=1000000;++i){
t = i;
while(t>0){
if(t%10 == 4||t%100 == 62)
m[i]++;
t /= 10;
}
}
}
int main(void)
{
int a,b,t,c;
p();
while(scanf("%d%d",&a,&b) != EOF&&(a||b)){
c = b-a+1;

for(int i = a;i<=b;++i){
 if(m[i] != 0)
 c -= 1;
}
cout<<c<<endl;
}
return 0;}

链接http://acm.hdu.edu.cn/showproblem.php?pid=2089

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值