AcWing
1245. 特别数的和
真·暴力。枚举1~n
的每一个数,判断是否有某一位是2/0/1/9
.
#include <bits/stdc++.h>
using namespace std;
int n;
int main(){
cin >> n;
int res = 0;
for(int i = 1; i <= n; i++){
int t = i;
while(t){
int r = t % 10;
if(r == 0 || r == 1 || r == 2 || r == 9){
res += i;
break;
}
t = t / 10;
}
}
cout << res;
return 0;
}