-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.cpp
More file actions
146 lines (138 loc) · 2.96 KB
/
template.cpp
File metadata and controls
146 lines (138 loc) · 2.96 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
//******Shree Krishna****************
//******Jai Hanuman******************
//******Saket Kumaer*****************
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define pi pair<int,int>
#define pl pair<long long, long long>
#define mp make_pair
#define f first
#define s second
#define pb push_back
#define scd(x) scanf("%d",&x)
#define scld(x) scanf("%ld",&x)
#define sclld(x) scanf("%lld",&x)
#define fo(i,n) for(int i=0;i<n;i++)
#define fof(i,k,n) for(int i=k;i<n;i++)
#define fob(i,k,n) for(int i=n-1;i>=k;i--)
#define modpro(a,b) ((a%mod)*(b%mod))%mod
#define modsum(a,b) ((a%mod)+(b%mod))%mod
#define no cout<<"NO\n"
//==================================================================================
const int mod = 1000000007;
const ll zero = 0;
//==================================================================================
//-----------------------FUNCTIONS-------------------------------------------------------------------------------------------------------
//---Returns x^n ---------
ll power(int x,int n)
{
int m = abs(n);
ll ans=1;
while(m)
{
if(m%2==0)
x=x*x;
else
{
ans=ans*x;
x=x*x;
}
m=m/2;
}
return ans;
}
//---Returns modular exponential---------
ll modularExponentiation(ll x,ll n,ll M)
{
ll result=1;
while(n>0)
{
if(n % 2 ==1)
result=modpro(result,x);
x=modpro(x,x);
n=n/2;
}
return result;
}
//Return GCD
int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
//Return LCM
int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
// Returns modulo inverse of a with respect
// to m using extended Euclid Algorithm
// Assumption: a and m are coprimes, i.e.,
// gcd(a, m) = 1
int modInverse(int a, int m)
{
int m0 = m, y = 0, x = 1;
if (m == 1)
return 0;
while (a > 1) {
// q is quotient
int q = a / m;
int t = m;
// m is remainder now, process same as
// Euclid's algo
m = a % m, a = t;
t = y;
// Update y and x
y = x - q * y;
x = t;
}
// Make x positive
if (x < 0)
x += m0;
return x;
}
// TC: O(RlogN)
ll ncr(ll n, ll r){
ll p = 1, k = 1;
if(n-r < r) r = n-r;
if(r!=0){
while(r){
p = p * n;
k = k *r;
ll m = __gcd(p,k);
p = p/m;
k = k/m;
n--; r--;
}
}
return p;
}
// asc sort
bool sortcol( const vector<ll>& v1,
const vector<ll>& v2 ) {
return v1 < v2;
}
//----------------------------------------------------------------------------------------------------------------------------------------
//__gcd(a,b) to calculate gcd of two numbers
/*
priority_queue <T, vector<T>, greater<T>> pq; // 30 20 10 5 1
cout << setprecision(12) << fixed << ans << '\n';
*/
void solve(){
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t = 1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}