Euphoria and quantum fluctuation speed reading

Euphoria and quantum fluctuation speed reading

http://qoj.xust-kcsoft.club/problem/10002

Careful analysis

Odd road,

The even road,

Finally, reverse output

#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    string s;
    cin >> n;
    while(n) {
        if(n&1) {
            s += 'A';
            n = (n - 1) >> 1;
        }
        else {
            s += 'B';
            n = (n - 2) >> 1;
        }
    }
    for(int i = s.size() - 1;i >= 0; -- i) cout << s[i];
    return 0;
}

Guess you like

Origin www.cnblogs.com/lukelmouse/p/12094380.html