1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | #include <bits/stdc++.h> long long n, m, t, a[1000005]; using namespace std; int main() { cin >> n >> m; while (m > 0) { t++; m--; if (m <= 0) break; a[t] = a[t - 1] + 1; while (m > (1 << n - a[t]) && a[t] <= n) { m -= 1 << n - a[t]; a[t]++; } } if (t != 1) for (int i = 1; i < t; i++) cout << a[i] << " "; else puts("0"); return 0; } |
0 of 6 Questions completed
Questions:
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading…
You must sign in or sign up to start the quiz.
You must first complete the following:
0 of 6 Questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 point(s), (0)
Earned Point(s): 0 of 0, (0)
0 Essay(s) Pending (Possible Point(s): 0)
16. 第 21 行的”0″改成’0’,程序运行会报错( )。
17. 输入的 n 如果是负整数,程序运行不会报错()。
18. 第 11 行的功能是对 a 数组求前缀和()。
19. 输入的 n 最大可以到 1000000( )。
20. 输入4 12, 输出( )