-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_old.cpp
More file actions
246 lines (191 loc) · 6.26 KB
/
template_old.cpp
File metadata and controls
246 lines (191 loc) · 6.26 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
/*
------------------------------------------- Author : Akhilesh Singh --------------------------------------
User Handle : akhilesh59
Disclaimer : Please do not copy my code, it will lead to Plagarism.
'Abe Padhai likhai pe dhyaan do, IAS-YAS bano aur desh ko sambhalo. Lekin nhi, tumko to SDE banna hai!'
*/
#include <bits/stdc++.h>
// #include <sys/resource.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
/*-------------------------------------------------------------------------------------------------------------------------*/
// Pragmas
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// template<typename T>
// using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// Aliases
using ll = long long;
using ull = unsigned long long;
using ld = long double;
// Constants
constexpr ll INF = 2e18;
constexpr ld EPS = 1e-9;
constexpr ll MOD = 998244353;//1e9 + 7;
// Operator overloads
template<typename T1, typename T2> // cin >> pair<T1, T2>
istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }
template<typename T> // cin >> vector<T>
istream& operator>>(istream &istream, vector<T> &v)
{
for (auto &it : v)
cin >> it;
return istream;
}
template<typename T1, typename T2> // cout << pair<T1, T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
template<typename T> // cout << vector<T>
ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }
/*----------------------------------------------------------------------------------------------------------------------*/
//----------------Functions---------------------//
//--------------------------------- Sieve of Eratosthenes -----------------------------------
vl sieveOfEratosthenes(ll n) {
vl arr(n+1);
for(ll i = 2; i <= n; i++) {
if(arr[i] == 0) {
for (ll j = i*i; j <= n; j += i)
{
arr[j] = 1;
}
}
}
// for(int i=2; i<=n; i++) {
// if(arr[i] == 0) cout<<i<<" ";
// }
// cout<<endl;
return arr;
}
//-----------------------------------------------------------------
vl prFactUsingSieve(ll n) {
vl arr(n+1);
vl ans;
for (ll i = 0; i <= n; i++) arr[i] = i;
for (ll i = 2; i <= n; i++)
{
if(arr[i] == i) {
for(ll j=i*i; j<=n; j+=i) {
if(arr[j] == j) {
arr[j] = i;
}
}
}
}
while(n != 1) {
// cout<<arr[n]<<" ";
ans.pb(arr[n]);
n /= arr[n];
}
return ans;
}
//--------------------------- Euclid's Algo ---------------------------------------------------
ll gcd(ll a, ll b) {
ll rem;
while(b) {
rem = a%b;
a = b;
b = rem;
}
return a;
}
int binaryGCD(int a, int b) {
if(!a || !b) { // if any of a,b is zero
return a | b; // then return the non-zero value
}
int commonMultiplesOf2 = __builtin_ctz(a|b); // yahi factors k product se multiply kar k last me answer return karna hai
a >>= __builtin_ctz(a); // a me se saare 2 k multiples nikal do (2nd point of Algo)
b >>= __builtin_ctz(b);
while(b) {
b >>= __builtin_ctz(b); // if only b is even we can simply neglect its multiples of 2
if(a>b) {
swap(a,b);
}
b -= a;
}
return (a << commonMultiplesOf2);
}
ll extendedEuclid2(ll a, ll b, ll& x, ll& y) { // without using struct, and this function will return
//GCD of a and b but will change the values of x and y at their respective addresses
if(b == 0) {
x = 1;
y = 0;
return a;
}
ll x1,y1;
ll gcd = extendedEuclid2(b ,(a%b) , x1, y1);
x = y1;
y = x1 - floor(a/b)*y1;
return gcd;
}
ll LCM(ll a, ll b)
{
return ((ll)a * b) / gcd(a, b);
}
//--------------------------------------- Binary Exponentiation -------------------------------------
ll binpow(ll a, ll b, ll m) {
a %= m;
ll res = 1;
while (b > 0) {
if (b & 1)
res = res * a % m;
a = a * a % m;
b >>= 1;
}
return res;
}
/*------------------------------------------------------------------------------------------------------------------*/
//------------------------------------------------------- Macros -----------------------------------------
#define vi vector<int>
#define vl vector<ll>
#define umpll unordered_map<ll, ll>
#define umpsl unordered_map<string, ll>
#define mkpr make_pair
#define Fien for (int i = 0; i <= n; i++)
#define Fln for (ll i = 0; i < n; i++)
#define pb push_back
#define complete(v) v.begin(), v.end()
#define itr_v for (auto it = v.begin(); it != v.end; it++)
#define sort_asc(v) sort(v.begin(), v.end())
#define sort_dec(v) sort(v.begin(), v.end(), greater<int>())
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
/*----------------------------------------------------------------------------------------------------------------*/
/*----------------------------- And My code Begins ---------------------------*/
void sol()
{
ll n;
cin >> n;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll t;
cin >> t;
while (t--)
{
sol();
}
return 0;
}
/*
*
* ┏┓ ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃ ┃
* ┃ ━ ┃ ++ + + +
* +████━████++
* ◥██◤ ◥██◤ +
* ┃ ┻ ┃
* ┃ ┃ + +
* ┗━┓ ┏━┛
* ┃ ┃ + + + +
* ┃ ┃ + Beware of the Dog
* ┃ ┗━━━┓
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛ + + + +
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛+ + + +
*/