代码
#include <bits/stdc++.h>
using namespace std;
bool check(int x) //短除法判断是否有当前数字
{
while(x){
if(x%10 == 2 || x%10 == 0 || x%10 == 1 || x%10 == 9)
return true;
x /= 10;
}
return false;
}
int main()
{
int n;
cin>>n;
int sum = 0;
for(int i=1; i<=n; i++) //枚举 + 简单check()
{
if(check(i))
sum += i;
}
cout<<sum;
}