File tree Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Expand file tree Collapse file tree 1 file changed +76
-0
lines changed Original file line number Diff line number Diff line change 1+
2+
3+ ll power(ll a,ll b){
4+ ll val=a;
5+
6+
7+ ll ans=1;
8+
9+ ll temp=b;
10+ while(temp!=0){
11+ if(temp%2){
12+ ans*=(val);
13+ ans%=mod;
14+ }
15+ val*=val;
16+ val%=mod;
17+ temp/=2;
18+ }
19+
20+ return ans;
21+
22+
23+
24+
25+ }
26+
27+ ll sum(ll x,ll y){
28+
29+ return (x%mod + y%mod)%mod;
30+
31+ }
32+
33+
34+ ll mul(ll x,ll y){
35+
36+ return ((x%mod)*(y%mod))%mod;
37+
38+ }
39+
40+
41+ ll subs(ll x,ll y){
42+ return (x%mod - y%mod + mod)%mod;
43+ }
44+
45+
46+
47+ ll fact[3000005];
48+ ll inver[3000005];
49+
50+ void calculate(){
51+ // cout<<"YES"<<endl;
52+
53+ fact[0]=1;
54+ fact[0]%=mod;
55+
56+
57+ for(ll i=1;i<=3000004;i++){
58+ fact[i]=(fact[i-1]*i)%mod;
59+ }
60+
61+ inver[3000004]=power(fact[3000004],mod-2);
62+
63+ for(ll i=3000004;i>0;i--){
64+ inver[i-1]=inver[i]*i;
65+ inver[i-1]%=mod;
66+ }
67+
68+
69+
70+ }
71+
72+
73+ ll nCr(ll n,ll r){
74+ return (((fact[n]*inver[r])%mod)*inver[n-r])%mod;
75+ }
76+
You can’t perform that action at this time.
0 commit comments