描述
小明非常不喜欢数字 22,包括那些数位上包含数字 22 的数。
如果一个数的数位不包含数字 22,小明将它称为洁净数。
请问在整数 11 至 nn 中,洁净数有多少个?
输入
输入的第一行包含一个整数nn。
输出
输出一行包含一个整数,表示答案。
样例
输入复制
30
输出复制
18
提示
评测用例规模与约定
对于 40%40% 的评测用例,1 <= n <= 100001<=n<=10000。
对于 80%80% 的评测用例,1 <= n <= 1000001<=n<=100000。
对于所有评测用例,1 <= n <= 10000001<=n<=1000000。
简单水题
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int n;
int res;
int main(){
cin >> n;
for (int i = 1; i <= n; i ++ ){
char s[100];
sprintf(s, "%d", i);
string str = s;
if (str.find("2") == string::npos) res ++;
}
cout << res << endl;
return 0;
}