[蓝桥杯][2019年第十届真题]特别数的和

水题。

const int N=10010;
int n;

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

int main()
{
    cin>>n;

    int res=0;
    for(int i=1;i<=n;i++)
        if(check(i))
            res+=i;
    cout<<res<<endl;
    //system("pause");
    return 0;
}
原文地址:https://www.cnblogs.com/fxh0707/p/14572564.html