-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnCr_find.cpp
66 lines (62 loc) · 912 Bytes
/
nCr_find.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
/*
maneesh(maik)
*/
#include<iostream>
#include<algorithm>
#include<string>
#include<bitset>
#include<deque>
#include<iterator>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define fastio ios_base::sync_with_stdio(false);
ll md=1e9+7;
ll fact[1000002],inv[1000002];
ll modex(ll a,ll p)
{
if(p==0)
return 1;
else if(p%2==1)
{
return (a*modex(a,p-1))%md;
}
else
{
ll y=modex(a,p/2)%md;
return (y*y)%md;
}
}
void calculate()
{
ll i,j,k;
fact[0]=1;
fact[1]=1;
for(i=2;i<=1000000;i++)
{
fact[i]=(fact[i-1]*i)%md;
}
for(i=0;i<=1000000;i++)
{
inv[i]=modex(fact[i],md-2);
}
}
ll ncr(ll n,ll r)
{
return (((fact[n]*inv[r])%md)*inv[n-r])%md;
}
int main()
{
calculate();
cout<<ncr(6,3);
return 0;
}