题解 | #扭蛋机#
扭蛋机
https://www.nowcoder.com/practice/9d26441a396242a9a0f7d2106fc130c7
#include <iostream> #include <string> #include <algorithm> using namespace std; void Calculate(int inx, string& outchars) { if (inx == 0)return; if (inx % 2 == 0) { int x = inx / 2 - 1; outchars.push_back('3'); Calculate(x, outchars); } else { int x = inx / 2; outchars.push_back('2'); Calculate(x, outchars); } } void BL1() { int n; while (cin >> n) { string tempresult; Calculate(n, tempresult); reverse(tempresult.begin(), tempresult.end()); cout << tempresult << endl; } } int main() { BL1(); }