10tps995
查看原帖
10tps995
1341489
sbl_xh楼主2024/12/4 21:45

除了第一个点其他是 WA

代码:

#include<bits/stdc++.h>
using namespace std;
int n;
char f(int x){
    int a,b;
    while(x){
        if((x%2)&1==1) a++;
        else b++;
        x>>=1;
    }
    if(a>b) return 'a';
    return 'b';
}
int main(){
    int a=0,b=0;
    cin >> n;
    for(int i = 1;i<=n;i++){
        if(f(i)=='a')a++;
        else b++;
    }
    cout << a << ' ' << b;
    return 0;
}

995 995 995 995 995 995 995 995 995 995 995 995 995 995

2024/12/4 21:45
加载中...