JAVA代码
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int sum = 0;
for(int i = 1; i <= n ;i++) {
if(check(i)) {
sum+=i;
}
}
System.out.println(sum);
}
private static boolean check(int i) {
while(i!=0) {
if(i%10==2||i%10==9||i%10==1||i%10==0) {
return true;
}
i/=10;
}
return false;
}
}