-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_template.cpp
More file actions
194 lines (174 loc) · 3.54 KB
/
my_template.cpp
File metadata and controls
194 lines (174 loc) · 3.54 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
// بسم الله الرحمن الرحيم
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define Hesham ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
//#define ordered_set tree<ll,null_type,less_equal<>,rb_tree_tag,tree_order_statistics_node_update>
#define fll(i,a,b) for(long long i=a;i<b;i++)
#define fllm(i,a,b) for(long long i=a;i>=b;i--)
#define f(b,a) cout << fixed << setprecision(b) << a << endl;
#define rall(x) x.rbegin(),x.rend()
#define MOD 1000000007
#define sub_mod(a,b,m) ((((a)%m)-((b)%m)+m)%m)
#define add_mod(a,b,m) ((((a)%m)+((b)%m))%m)
#define mult_mod(a,b,m) ((((a)%m)*((b)%m))%m)
#define pi 3.14159265358979323846
#define all(x) x.begin(),x.end()
#define ull unsigned long long
#define ld long double
#define ll long long
#define sz(s) s.size()
#define yes cout << "YES" << nl
#define no cout << "NO" << nl
#define F first
#define S second
#define nl '\n'
using namespace std;
//using namespace __gnu_pbds;
const int m=998244353;
const int maxn=100000;
vector<ll>fact(maxn,1),inv(maxn,1);
vector<bool>sieve(maxn+1,1);
vector<ll>spf(maxn); vector<ll>divs[100001];
ll dx[] = {0, -1, 1, 0};
ll dy[] = {1, 0, 0, -1};
bool isPrime(ll n)
{
if(n==1||(n%2==0&&n!=2)) return false;
for(ll j=2;j*j<=n;j++)
{
if(n%j==0)
{
return false;
}
}
return true;
}
void sev()
{
for(ll i=2;i*i<=maxn;i++)
{
if(sieve[i])
{
for(ll j=i*i;j<=maxn;j+=i)
{
sieve[j]=0;
}
}
}
sieve[1]=0,sieve[0]=0;
}
void smallestpf()
{
spf[1]=1;
fll(i,2,maxn) spf[i]=i;
for(ll i=4;i<maxn;i+=2) spf[i]=2;
for(ll i=3;i*i<maxn;i++)
{
if(spf[i]==i)
{
for(ll j=i*i;j<maxn;j+=i)
if(spf[j]==j) spf[j]=i;
}
}
}
vector<ll>getf(ll n)
{
vector<ll>ret;
while(n!=1)
{
ret.push_back(spf[n]);
n=n/spf[n];
}
return ret;
}
bool comp(pair<ll,ll>p1,pair<ll,ll>p2)
{
return p1.S<p2.S;
}
ll fastpower(ll x,ll n,ll m)
{
ll res=1;
while(n>0)
{
if(n%2!=0) res=(res%m*x%m)%m,n--;
else x=(x%m*x%m)%m,n/=2;
}
return res;
}
vector<ll>presum(vector<ll> &v)
{
vector<ll>p(v.size());
fll(i,0,v.size())
{
if(i==0) p[i]=v[i];
else p[i]=v[i]+p[i-1];
}
return p;
}
multiset<ll>primefactor(ll n)
{
ll cn=0; multiset<ll>v;
while(n%2==0)
{
v.insert(2); n/=2;
}
for(ll j=3;j*j<=n;j+=2)
{
while(n%j==0)
{
v.insert(j);
n/=j;
}
}
if(n>2) v.insert(n);
return v;
}
vector<ll>divisors(ll n)
{
vector<ll>c;
for(ll i=1;i*i<=n;i++)
{
if(n%i==0)
{
c.push_back(i);
if(n/i!=i) c.push_back(n/i);
}
}
return c;
}
ll lcm(ll a,ll b)
{
ll k=(a*b)/__gcd(a,b);
return k;
}
ll arteq(ll l,ll r,ll p)
{
ll k=((r-l)/p)+1;
ll h=k*(l*2+(k-1)*p); h/=2;
return h;
}
ll binpow(ll a,ll b,ll p=m)
{
ll res=1;
while(b>0)
{
if(b&1) res*=a,res%=p;
a*=a,a%=p;
b>>=1;
}
return res;
}
void solve()
{
}
int main()
{
Hesham;
// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);
ll t=1;
cin >> t;
while(t--) solve();
return 0;
}