-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFermatLittleTheoremInverse.cpp
More file actions
83 lines (59 loc) · 1.5 KB
/
FermatLittleTheoremInverse.cpp
File metadata and controls
83 lines (59 loc) · 1.5 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
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define for0(i,n) for(int i=0;i<n;++i)
#define for1(i,n) for(int i=1;i<=n;++i)
#define ford(i,n) for(int i=n-1;i>=0;--i)
#define forg(i,a,b) for(int i=a;i<b;++i)
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(0);
#define deb(x) cout << #x << " " << x << endl;
// template<typename... T>
// void read(T&... args) {
// ((cin >> args), ...);
// }
// template<typename... T>
// void write(T... args) {
// ((cout << args << " "), ...);
// }
ll powmod (ll a, ll b, ll c) {
ll res = 1;
a = a % c;
if (a == 0) return 0;
while (b > 0) {
if (b&1) {
res = (res%c * a%c) % c;
}
b = b>>1;
a = (a%c * a%c) % c;
}
return (res % c);
}
ll inverse(ll a, ll p) {
return powmod(a, p-2, p);
}
/*
// theory
USED IN nCk to calc big integer denominator modulo
nCk = n!/((k!) * (n-k)!)
nCk (mod p) = ( (n!)*(mod p) * inv(k!)*(mod p) * inv((n-k)!)*(mod p) ) * (mod p)
---------------------------
a^p = a (mod p)
a^(p-1) = 1 (mod p)
a * inv(a) = a^(p-1) (mod p)
inv(a) = a^(p-2) (mod p)
USE ExpoModular.
a^b = ( (a^2) ^ (b/2) ) // even
a^b = ( a * a^(b-1) )
*/
int main () {
int a, b, c;
// ll a, b, c;
cin >> a >> b >> c;
// 71045970 41535484 64735492
return 0;
}