http://qoj.xust-kcsoft.club/problem/10002
仔细分析
奇数一条路,
偶数一条路,
最后倒序输出
- #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;
- }
来源: http://www.bubuko.com/infodetail-3348805.html