-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.cpp
More file actions
373 lines (320 loc) · 8.86 KB
/
tmp.cpp
File metadata and controls
373 lines (320 loc) · 8.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
#ifdef ONPC
#include <sys/resource.h>
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wrange-loop-construct"
#pragma GCC diagnostic ignored "-Wsign-compare"
#endif
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
using namespace __gnu_pbds;
bool startmemory;
#define endln "\n"
#define EPSILON 1e-12
#define int long long
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)
#ifdef ONPC
#include "Debug/debug.h"
#else
#define print(...) 42
#define printarr(...) 42
#endif
#define MULTI \
int _T; \
cin >> _T; \
while (_T--)
int test_cases = 1;
const int INF = 1e18; // infinity
const int mod = 1e9 + 7; // mod
const int base1 = 972663749; // base1
const int base2 = 998244353; // base2
const int mod1 = 1e9 + 7; // mod1
const int mod2 = 1e9 + 9; // mod2
const double pi = 4 * atan(1);
vector<int> dx = {-1, +1, +0, +0, +1, -1, +1, -1};
vector<int> dy = {+0, +0, +1, -1, +1, -1, -1, +1};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/////////////////////////////////////////////////////////////////////////////////////
template <class T>
bool ckmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template <class T>
bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template <class T>
using maxheap = priority_queue<T, vector<T>>;
template <class T>
using minheap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
using ordered_set = tree<T, null_type,
less<T>, rb_tree_tag,
tree_order_statistics_node_update>;
template <const int32_t MOD>
struct modint
{
int32_t value;
modint() = default;
modint(int32_t value_) : value(value_) {}
inline modint<MOD> operator+(modint<MOD> other) const
{
int32_t c = this->value + other.value;
return modint<MOD>(c >= MOD ? c - MOD : c);
}
inline modint<MOD> operator-(modint<MOD> other) const
{
int32_t c = this->value - other.value;
return modint<MOD>(c < 0 ? c + MOD : c);
}
inline modint<MOD> operator*(modint<MOD> other) const
{
int32_t c = (int64_t)this->value * other.value % MOD;
return modint<MOD>(c < 0 ? c + MOD : c);
}
inline modint<MOD> &operator+=(modint<MOD> other)
{
this->value += other.value;
if (this->value >= MOD)
this->value -= MOD;
return *this;
}
inline modint<MOD> &operator-=(modint<MOD> other)
{
this->value -= other.value;
if (this->value < 0)
this->value += MOD;
return *this;
}
inline modint<MOD> &operator*=(modint<MOD> other)
{
this->value = (int64_t)this->value * other.value % MOD;
if (this->value < 0)
this->value += MOD;
return *this;
}
inline modint<MOD> operator-() const { return modint<MOD>(this->value ? MOD - this->value : 0); }
modint<MOD> pow(uint64_t k) const
{
modint<MOD> x = *this, y = 1;
for (; k; k >>= 1)
{
if (k & 1)
y *= x;
x *= x;
}
return y;
}
modint<MOD> inv() const { return pow(MOD - 2); } // MOD must be a prime
inline modint<MOD> operator/(modint<MOD> other) const { return *this * other.inv(); }
inline modint<MOD> operator/=(modint<MOD> other) { return *this *= other.inv(); }
inline bool operator==(modint<MOD> other) const { return value == other.value; }
inline bool operator!=(modint<MOD> other) const { return value != other.value; }
inline bool operator<(modint<MOD> other) const { return value < other.value; }
inline bool operator>(modint<MOD> other) const { return value > other.value; }
};
template <int32_t MOD>
modint<MOD> operator*(int64_t value, modint<MOD> n) { return modint<MOD>(value) * n; }
template <int32_t MOD>
modint<MOD> operator*(int32_t value, modint<MOD> n) { return modint<MOD>(value % MOD) * n; }
template <int32_t MOD>
istream &operator>>(istream &in, modint<MOD> &n) { return in >> n.value; }
template <int32_t MOD>
ostream &operator<<(ostream &out, modint<MOD> n) { return out << n.value; }
void setIO(string s)
{
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
int modpower(int x, int n, int m)
{
if (n == 0)
return 1 % m;
int u = modpower(x, n / 2, m);
u = (u * u) % m;
if (n % 2 == 1)
u = (u * x) % m;
return u;
}
int power(int x, int n)
{
if (n == 0)
return 1;
int u = power(x, n / 2);
u = (u * u);
if (n % 2 == 1)
u = (u * x);
return u;
}
int modinverse(int i, int MOD)
{
if (i == 1)
return 1;
return (MOD - ((MOD / i) * modinverse(MOD % i, MOD)) % MOD + MOD) % MOD;
}
int lcm(int x1, int x2)
{
return ((x1 * x2) / __gcd(x1, x2));
}
bool isPowerOf2(int x)
{
return x > 0 && (x & (x - 1)) == 0;
}
void printVector(vector<int> &array, int startIndex = 0)
{
int sz = array.size();
if (sz == 0)
return;
sz += startIndex;
for (int i = startIndex; i < sz - 1; i++)
{
cout << array[i] << " ";
}
cout << array[sz - 1] << endl;
}
void printArray(int array[], int sz, int startIndex = 0)
{
sz += startIndex;
for (int i = startIndex; i < sz - 1; i++)
{
cout << array[i] << " ";
}
cout << array[sz - 1] << endl;
}
template <typename T, typename T_iterable>
vector<pair<T, int>> run_length_encoding(const T_iterable &items)
{
vector<pair<T, int>> runs;
T previous;
int count = 0;
for (const T &item : items)
if (item == previous)
{
count++;
}
else
{
if (count > 0)
runs.emplace_back(previous, count);
previous = item;
count = 1;
}
if (count > 0)
runs.emplace_back(previous, count);
return runs;
}
struct BIT
{
int size;
vector<int> bit;
BIT(int n) : size(n + 4), bit(n + 10) {}
void update(int x, int v)
{
for (; x <= size; x += x & (-x))
bit[x] += v;
}
int query(int b)
{
int result = 0;
for (; b > 0; b -= b & (-b))
result += bit[b];
return result;
}
int query(int l, int r)
{
return query(r) - query(l - 1);
}
};
int rand(int low, int high)
{
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<int> distribution(low, high);
return distribution(gen);
}
int sumton(int x)
{
double n = (-1 + sqrt(1 + 8 * x)) / 2;
int nn = n;
if ((n - nn) > 1e-6)
return -1;
else
return nn;
}
int rangesum(int l, int r)
{
return (r - l + 1) * (r + l) / 2;
}
//////////////////////////////////////----main-function----///////////////////////////////////////////
//====================================================================================================
//====================================================================================================
const int N = 2e6 + 5;
const int K = 3e5 + 5;
// FUV
char ch;
string s, s1, s2;
int n, m, b, a, c, d, e, f, l, r, t, x, y, z, p, q, k, u, v, i, w, h;
// My Defination
// https://cses.fi/problemset/task/2413
// https://cses.fi/problemset/task/1744
// https://cses.fi/problemset/task/1653
// https://cses.fi/problemset/task/2181
const int magic = 600;
using z1 = modint<mod>;
void pre_process()
{
}
void solve_the_problem(int test_case)
{
/*
Please check the value of N :(
Please read the problem again before coding !
*/
cin >> n;
int tmp = n;
int ans = 1;
while (tmp)
{
tmp /= 2;
ans *= 2;
}
for (int i = 1; i <= n; i++)
{
cout << ans + 1 << " \n"[i == n];
}
}
bool endmemory;
signed main()
{
#ifdef ONPC
const rlim_t stackSize = 1024 * 1024 * 1024; // 1 GB
struct rlimit rl;
rl.rlim_cur = stackSize;
rl.rlim_max = stackSize;
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed << setprecision(14);
#ifdef ONPC
char name[] = "input.txt";
freopen(name, "r", stdin);
freopen("output.txt", "w", stdout);
#endif
pre_process();
cin >> test_cases;
for (int test_case = 1; test_case <= test_cases; test_case++)
{
// cout << "Case " << test_case << ": ";
solve_the_problem(test_case);
#ifdef ONPC
// cout << "================================================================" << endln;
#endif
}
#ifdef ONPC
if (setrlimit(RLIMIT_STACK, &rl) != 0)
std::cerr << "Error setting stack size: " << strerror(errno) << std::endl;
cout << "Stack size: " << stackSize / 1024 / 1024 / 1024 << "GB \n";
cout << "Execution Time : " << 1.0 * clock() / CLOCKS_PER_SEC << "s\n";
cout << "Execution Memory : " << (&endmemory - &startmemory) / (1024 * 1024) << "MB\n";
#endif
return 0;
}