We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e96001d commit 553af98Copy full SHA for 553af98
Other_Tasks/CF2072_C_Creating_Keys_for_StORages_Has_Become_My_Main_Skill.cpp
@@ -0,0 +1,40 @@
1
+#pragma GCC optimize("Ofast")
2
+#pragma GCC optimize("unroll-loops")
3
+#include <bits/stdc++.h>
4
+using namespace std;
5
+
6
+int main() {
7
+ int tc;
8
+ cin >> tc;
9
+ while (tc--) {
10
+ int n, x;
11
+ cin >> n >> x;
12
13
+ vector<int> ans;
14
+ int i = 0;
15
+ int orSoFar = 0;
16
+ for (; i < n - 1; i++) {
17
+ if ((i & x) == i) {
18
+ orSoFar |= i;
19
+ ans.push_back(i);
20
+ } else {
21
+ break;
22
+ }
23
24
25
+ if (i == n - 1 && (i | orSoFar) == x) {
26
27
28
+ for (; i < n; i++) {
29
+ ans.push_back(x);
30
31
32
33
+ for (int i = 0; i < n; i++) {
34
+ cout << ans[i] << " ";
35
36
+ cout << endl;
37
38
39
+ return 0;
40
+}
0 commit comments