-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcpp.json
More file actions
216 lines (216 loc) · 5.25 KB
/
cpp.json
File metadata and controls
216 lines (216 loc) · 5.25 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
{
"PS head":
{
"prefix": ["hd"],
"body": [
"/* Code By [ Your Handle ]",
"GitHub : [ Your Handle ] */",
"",
"#include <bits/stdc++.h>",
"using namespace std;",
"#define ll long long int",
"#define INF (ll)999999999999",
"#define mod (ll)1000000007",
"#define amod (ll)998244353",
"#define all(v) (v).begin(), (v).end()",
"",
"#define debug if constexpr (local) std::cout",
"#define endl '\\n'",
"",
"#ifdef ONLINE_JUDGE",
"constexpr bool local = false;",
"#else",
"constexpr bool local = true;",
"#endif",
"",
"void fastio() {",
" ios::sync_with_stdio(false);",
" cin.tie(0);",
"}",
"",
"int main() {",
" fastio();",
" $0",
"}"
],
"description": "make head"
},
"test-case-templete":
{
"prefix": ["tc"],
"body": [
"int T;",
"cin >> T;",
"while(T--) { ",
" $0",
"}"
],
"description": "make test case templete"
},
"repeat1":
{
"prefix": ["rep1"],
"body": [
"for(int i=0; i<N; i++) {",
" $0",
"}"
],
"description": "make repeat-1 templete"
},
"repeat2":
{
"prefix": ["rep2"],
"body": [
"for(int i=0; i<N; i++) {",
" for(int j=0; j<N; j++) {",
" $0",
" }",
"}"
],
"description": "make repeat-2 templete"
},
"fibobasic":
{
"prefix": ["fib"],
"body": [
"vector<ll> fibo(1000005);",
"for(int h=1; h<=1000000; h++) {",
" if(h==1 || h==2) {",
" fibo[h]=1;",
" } else {",
" fibo[h]=fibo[h-1]+fibo[h-2];",
" }",
"}",
],
"description": "make fibonacci basic templete"
},
"bigint_sum":
{
"prefix": ["ssum"],
"body": [
"string ssum(string sa, string sb) {",
" int tmp = 0;",
" string res = \"\";",
" while(!sa.empty() || !sb.empty() || tmp) {",
" if(!sa.empty()) {",
" tmp += (sa.back() - '0');",
" sa.pop_back();",
" }",
" if(!sb.empty()) {",
" tmp += (sb.back() - '0');",
" sb.pop_back();",
" }",
" res += ((tmp%10) + '0');",
" tmp /= 10;",
" }",
" reverse(all(res));",
" return res;",
"}",
""
],
"description": "make bigint_sum templete"
},
"mers_p":
{
"prefix": ["mers_p"],
"body": [
"bool mers_p(int R) {",
" int tmp = 1;",
" bool f=false;",
" while(tmp <= 2^31) {",
" tmp<<=1;",
" if(tmp == R+1) {",
" f=true;",
" break;",
" }",
" }",
" if(!f) {",
" return false;",
" } else {",
" for(int k=2; k<=(int)sqrt(R); k++) {",
" if(R%k == 0) return false;",
" }",
" }",
" return true;",
"}",
""
],
"description": "make meresenne_prime_check templete"
},
"geom": {
"prefix": "geom",
"body": [
"struct Point {",
" int x = 0;",
" int y = 0;",
"};",
"",
"Point pipo(pair<int, int> Z) {",
" Point tmp;",
" tmp.x = Z.first;",
" tmp.y = Z.second;",
" return tmp;",
"}",
"",
"double dist(Point A, Point B) {",
" return sqrt((A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y));",
"}",
"",
"struct Point_d {",
" double x = 0;",
" double y = 0;",
"};",
"",
"Point_d pipo_d(pair<double, double> Z) {",
" Point_d tmp;",
" tmp.x = Z.first;",
" tmp.y = Z.second;",
" return tmp;",
"}",
"",
"double dist_d(Point_d A, Point_d B) {",
" return sqrt((A.x-B.x)*(A.x-B.x) + (A.y-B.y)*(A.y-B.y));",
"}"
],
"description": "make geometry template"
},
"mkmodulo": {
"prefix": "mkmodulo",
"body": [
"template<unsigned int P, unsigned int PHI = P - 1>",
"class Modulo {",
"private:",
" long long n;",
"",
"public:",
" Modulo() {}",
" constexpr Modulo(long long _n) : n(_n >= 0 ? _n % P : (P - (-_n % P)) % P) {}",
" constexpr Modulo operator+(const Modulo& rhs) const {return Modulo((n + rhs.n) % P);}",
" constexpr Modulo& operator+=(const Modulo& rhs) {*this = *this + rhs; return *this;}",
" constexpr Modulo operator-() const {return n == 0 ? Modulo(0) : Modulo(P - n);}",
" constexpr Modulo operator-(const Modulo& rhs) const {return *this + (-rhs);}",
" constexpr Modulo& operator-=(const Modulo& rhs) {(*this) = (*this) - rhs; return *this;}",
" constexpr Modulo operator*(const Modulo& rhs) const {return Modulo((n * rhs.n) % P);}",
" constexpr Modulo& operator*=(const Modulo& rhs) {(*this) = (*this) * rhs; return *this;}",
" friend ostream& operator << (ostream &out, Modulo t){ return out << t.n; }",
"",
" [[nodiscard]] constexpr Modulo pow(unsigned long long powered) const {",
" if (powered <= 1) {",
" return powered == 0 ? 1 : *this;",
" }",
" Modulo hold = pow(powered / 2);",
" return powered % 2 == 0 ? hold * hold : hold * hold * (*this);",
" }",
" [[nodiscard]] constexpr Modulo inverse() const {return this->pow(PHI - 1);}",
" constexpr Modulo operator/(const Modulo& rhs) const {",
" if (rhs == 0) {throw std::logic_error(\"DIV BY ZERO\");}",
" return *this * rhs.inverse();",
" }",
" constexpr Modulo& operator/=(const Modulo& rhs) {*this = *this / rhs; return *this;}",
" constexpr bool operator==(const Modulo& rhs) const {return n == rhs.n;}",
" constexpr explicit operator int() const {return static_cast<int>(n);}",
"};"
],
"description": "make modulo class"
}
}