题目(材料题)
01 #include <iostream>
02 using namespace std;
03 int main() {
04 int n;
05 cin >> n;
06 int x = 1, y = 1;
07 while (n > 0) {
08 if (n % 2 == 0) {
09 ++x;
10 } else {
11 ++x;
12 ++y;
13 }
14 n = n / 2;
15 }
16 cout << x << ' ' << y << endl;
17 return 0;
18 }
以下问题均假定输入的n为不超过$2^{31}-1$的非负整数。
||

关注我们