不要62
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 42261 Accepted Submission(s): 15429
Problem Description
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
Input
输入的都是整数对n、m(0<n≤m<1000000),如果遇到都是0的整数对,则输入结束。
Output
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
Sample Input
1 100 0 0
Sample Output
80
Author
qianneng
Source
Recommend
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include <set>
#include<algorithm>
#include <limits.h>
#include <ctype.h>
#include <map>
#include <stack>
#include <sstream>
typedef long long LL;
using namespace std;
const int N = 105;
int data[N][N];
int dp[N][N];
int f[35];
char c[6] = {'A', 'B', 'C', 'D', 'E', 'F'};
float obj[5];
void fun(int n, int m)
{
int flag = 0;
if(n < 0){
flag = 1;
n = -n;
}
stack<char> s1;
while(n != 0){
int yushu = n % m;
if(yushu >= 10){
s1.push(c[yushu - 10]);
}else {
s1.push(yushu + '0');
}
n = n / m;
}
if(flag){
cout << "-";
}
while(!s1.empty()){
cout << s1.top();
s1.pop();
}
cout << endl;
}
int gcd(int a, int b)
{
return b == 0 ? a : gcd(b, a % b);
}
int lcm(int a, int b)
{
return a / gcd(a, b) * b;
}
int fun1(int n) //看是否含有4
{
while(n != 0){
int yushu = n % 10;
if(yushu == 4){
return 1;
}
n = n / 10;
}
return 0;
}
int fun2(int a) //看是否含有62
{
stringstream ss;
ss << a;
string s = ss.str();
//cout << s << endl;
if(s.find("62") == string::npos){
return 0;
}else {
return 1;
}
}
bool isLaoer[1000001];
void Biao()
{
for(int i = 1; i <= 1000000; i++){
int temp = i;
while(temp != 0){
if(temp % 10 == 4 || temp % 100 == 62){
isLaoer[i] = true;
}
temp = temp / 10;
}
}
}
int main() {
//freopen("out.txt","w",stdout);
// int n, sum;
// while(scanf("%d %d", &n, &sum) != EOF){
// if(n == 0 && sum == 0) break;
// for(int i = 1; i <= n; i++){
// int T = 0;
// for(int j = i; j <= n; j++){
// T += j;
// if(T == sum ){
// cout << "["<< i << "," << j <<"]"<< endl;
// break;
// }else if(T < sum){
// continue;
// }else {
// break;
// }
// }
// }
// cout << endl;
// }
//freopen("in.txt","r",stdin);
int n, m;
Biao();
while(cin >> n >> m){
set<int> s1;
if(n == 0 && m == 0) break;
int ans = 0;
for(int i = n; i <= m; i++){
if(!isLaoer[i]){
ans ++;
}
}
cout << ans << endl;
}
return 0;
}