solution.cpp 414 字节
Newer Older
每日一练社区's avatar
每日一练社区 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
#include <iostream>

using namespace std;

int ans, n;

bool check(int n)
{
    while (n)
    {
        int tmpn = n % 10;
        if (tmpn == 2 || tmpn == 0 || tmpn == 1 || tmpn == 9)
            return true;
        n /= 10;
    }
    return false;
}

int main()
{
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        if (check(i))
            ans += i;
    }

    cout << ans << endl;

    return 0;
}