-
Notifications
You must be signed in to change notification settings - Fork 10
/
mth.sublime-snippet
54 lines (48 loc) · 1.04 KB
/
mth.sublime-snippet
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
<snippet>
<content><![CDATA[
template<typename T>
T sum(T x) {
return x % mod;
}
template<typename T , typename... Tail>
T sum(T x , Tail... extra) {
return (x % mod + sum(extra...) % mod) % mod;
}
template<typename T>
T sub(T x) {
return x % mod;
}
template<typename T , typename... Tail>
T sub(T x , Tail... extra) {
return (x - sub(extra...) + mod ) % mod;
}
template<typename T>
T mul(T x) {
return x % mod;
}
template<typename T , typename... Tail>
T mul(T x , Tail... extra) {
return (long long)(x % mod + mul(extra...) % mod) % mod;
}
template<typename T , typename U>
T power(T x , U p) {
T ans = 1 % mod;
while(p) {
if(p&1) {
ans = (T)(ans * x) % mod
}
p >>= 1;
x = (T) (x * x) % mod;
}
return ans;
}
template<typename T>
T inv(T x) {
return power(x , mod - 2);
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>maths</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>