蓝桥/15/B.1/好数

点击查看代码
#include<bits/stdc++.h>
using namespace std;

int n;
int main()
{
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        bool ok=true;
        int x=i;
        int p=1;
        while(x){
            if((x&1)!=p){
               ok=false;
               break;
            }
            x/=10;
            p^=1;
        }
        ans+=ok;
    }
    
    cout<<ans<<"\n";
    
    return 0;
}
posted @ 2026-03-04 13:35  AnoSky  阅读(3)  评论(0)    收藏  举报