-
Notifications
You must be signed in to change notification settings - Fork 0
/
Templates.cpp
107 lines (91 loc) · 2.43 KB
/
Templates.cpp
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
/*****************************
Author: Mukul C. Mahadik
******************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef string str;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef map<int, int> mii;
typedef map<ll, ll> mll;
typedef vector <pair<int, int>> vpii;
#define F first
#define S second
#define pb push_back
#define mk(arr,n,type) type *arr = new type[n]
#define fo(i,n) for(i=0; i<n; i++)
#define pnl(n) fo(i,n) {cout << endl;}
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%ll\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define sd(x) scanf("%lf\n", &x)
#define ss(x) scanf("%s", x)
#define MAX INT_MAX
#define MIN INT_MIN
#define NIL -1
#define gcd __gcd
const int mod = 1000000007;
int mpow(int base, int exp);
void fastscan(void)
{
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
vl accept_delim_str()
{
vl temp;
str str1;
getline(cin,str1);
stringstream sstr(str1);
for(int i; sstr >> i;)
{
temp.push_back(i);
if(sstr.peek() == ' ' || sstr.peek() == ',')
sstr.ignore();
}
}
vs accept (int n)
{
vs nums;
str strng,word;
getline(cin,strng);
stringstream strgstr(strng);
while(getline(strgstr,word,' '))
nums.push_back(word);
return nums;
}
int mpow(int base, int exp)
{
base %= mod;
int result = 1;
while (exp > 0)
{
if (exp & 1) result = ((ll)result * base) % mod;
base = ((ll)base * base) % mod;
exp >>= 1;
}
return result;
}
long long mod(string num, int a)
{
// Initialize result
long long res = 0;
// One by one process all digits of 'num'
for (int i = 0; i < num.length(); i++)
res = (res*10 + (int)num[i] - '0') %a;
return res;
}
int main()
{
fastscan();
return 0;
}