很简单的一道模拟题,只需要通过暴搜加一个简单的判断就行了
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n;
int sum;
bool check(int a)
{
int tmp;
while(a)
{
tmp = a % 10;
if(tmp == 2 || tmp == 0 || tmp == 1 || tmp == 9) return true;
a /= 10;
}
return false;
}
int main()
{
cin >> n;
for(int i = 1;i <= n;i++)
{
if(check(i)) sum += i;
}
cout << sum << endl;
return 0;
}