QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#397423 | #2568. Mountains | Naganohara_Yoimiya | AC ✓ | 1ms | 7940kb | C++14 | 1.5kb | 2024-04-24 07:41:44 | 2024-04-24 07:41:46 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define mk make_pair
#define fi first
#define se second
using namespace std;
inline int read(){
int x=0,f=1;char c=getchar();
for(;(c<'0'||c>'9');c=getchar()){if(c=='-')f=-1;}
for(;(c>='0'&&c<='9');c=getchar())x=x*10+(c&15);
return x*f;
}
const int mod=1e9+7;
int ksm(int x,ll y,int p=mod){
int ans=1;y%=(p-1);
for(int i=y;i;i>>=1,x=1ll*x*x%p)if(i&1)ans=1ll*ans*x%p;
return ans%p;
}
int inv(int x,int p=mod){return ksm(x,p-2,p)%p;}
mt19937 rnd(time(0));
int randint(int l,int r){return rnd()%(r-l+1)+l;}
void add(int &x,int v){x+=v;if(x>=mod)x-=mod;}
void Mod(int &x){if(x>=mod)x-=mod;}
int cmod(int x){if(x>=mod)x-=mod;return x;}
template<typename T>void cmax(T &x,T v){x=max(x,v);}
template<typename T>void cmin(T &x,T v){x=min(x,v);}
const int N=3e6+5;
int n,m,k,fac[N],ifac[N],Inv[N];
void init(int V){
fac[0]=1;for(int i=1;i<=V;i++)fac[i]=1ll*fac[i-1]*i%mod;
ifac[V]=inv(fac[V]);for(int i=V-1;i>=0;i--)ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
for(int i=1;i<=V;i++)Inv[i]=1ll*fac[i-1]*ifac[i]%mod;
}
ll C2(int x){
if(x<=1)return 0ll;
return 1ll*x*(x-1)/2;
}
signed main(void){
#ifndef ONLINE_JUDGE
freopen("in.in","r",stdin);
#endif
n=read(),m=read(),k=read();
int ans=1;init(n+m+k);
for(int i=3;i<=n+m+k;i++){
ll cc=C2(i-1)-C2(i-n-1)-C2(i-m-1)-C2(i-k-1)+C2(i-n-m-1)+C2(i-n-k-1)+C2(i-m-k-1);
ans=1ll*ans*ksm(1ll*Inv[i-2]%mod*(i-1)%mod,cc)%mod;
}
cout<<ans<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 7808kb
input:
1 1 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 1ms
memory: 7812kb
input:
2 2 2
output:
20
result:
ok 1 number(s): "20"
Test #3:
score: 0
Accepted
time: 1ms
memory: 7896kb
input:
2 3 4
output:
490
result:
ok 1 number(s): "490"
Test #4:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
1 2 8
output:
45
result:
ok 1 number(s): "45"
Test #5:
score: 0
Accepted
time: 1ms
memory: 7808kb
input:
1 10 2
output:
66
result:
ok 1 number(s): "66"
Test #6:
score: 0
Accepted
time: 1ms
memory: 7808kb
input:
9 5 7
output:
371850968
result:
ok 1 number(s): "371850968"
Test #7:
score: 0
Accepted
time: 1ms
memory: 7884kb
input:
3 3 1
output:
20
result:
ok 1 number(s): "20"
Test #8:
score: 0
Accepted
time: 1ms
memory: 7868kb
input:
7 7 9
output:
166345303
result:
ok 1 number(s): "166345303"
Test #9:
score: 0
Accepted
time: 1ms
memory: 7808kb
input:
25 15 25
output:
850087558
result:
ok 1 number(s): "850087558"
Test #10:
score: 0
Accepted
time: 0ms
memory: 7936kb
input:
45 59 71
output:
659153227
result:
ok 1 number(s): "659153227"
Test #11:
score: 0
Accepted
time: 1ms
memory: 7880kb
input:
73 3 25
output:
683124269
result:
ok 1 number(s): "683124269"
Test #12:
score: 0
Accepted
time: 0ms
memory: 7732kb
input:
1 48 78
output:
446896916
result:
ok 1 number(s): "446896916"
Test #13:
score: 0
Accepted
time: 0ms
memory: 7804kb
input:
25 100 32
output:
966287506
result:
ok 1 number(s): "966287506"
Test #14:
score: 0
Accepted
time: 1ms
memory: 7736kb
input:
85 64 40
output:
125679545
result:
ok 1 number(s): "125679545"
Test #15:
score: 0
Accepted
time: 1ms
memory: 7864kb
input:
5 9 94
output:
620471576
result:
ok 1 number(s): "620471576"
Test #16:
score: 0
Accepted
time: 1ms
memory: 7868kb
input:
33 57 40
output:
637315057
result:
ok 1 number(s): "637315057"
Test #17:
score: 0
Accepted
time: 1ms
memory: 7808kb
input:
61 6 97
output:
362472796
result:
ok 1 number(s): "362472796"
Test #18:
score: 0
Accepted
time: 1ms
memory: 7872kb
input:
85 50 51
output:
192099209
result:
ok 1 number(s): "192099209"
Test #19:
score: 0
Accepted
time: 1ms
memory: 7684kb
input:
96 54 59
output:
714762612
result:
ok 1 number(s): "714762612"
Test #20:
score: 0
Accepted
time: 0ms
memory: 7808kb
input:
20 99 12
output:
772155662
result:
ok 1 number(s): "772155662"
Test #21:
score: 0
Accepted
time: 1ms
memory: 7936kb
input:
48 39 62
output:
670046604
result:
ok 1 number(s): "670046604"
Test #22:
score: 0
Accepted
time: 1ms
memory: 7688kb
input:
76 83 16
output:
976820079
result:
ok 1 number(s): "976820079"
Test #23:
score: 0
Accepted
time: 1ms
memory: 7884kb
input:
96 36 61
output:
20854557
result:
ok 1 number(s): "20854557"
Test #24:
score: 0
Accepted
time: 1ms
memory: 7812kb
input:
18 40 77
output:
261684871
result:
ok 1 number(s): "261684871"
Test #25:
score: 0
Accepted
time: 1ms
memory: 7804kb
input:
42 84 26
output:
458573307
result:
ok 1 number(s): "458573307"
Test #26:
score: 0
Accepted
time: 1ms
memory: 7868kb
input:
71 25 80
output:
875902815
result:
ok 1 number(s): "875902815"
Test #27:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
95 73 26
output:
922299967
result:
ok 1 number(s): "922299967"
Test #28:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
19 17 83
output:
494148696
result:
ok 1 number(s): "494148696"
Test #29:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
100 100 100
output:
192912055
result:
ok 1 number(s): "192912055"
Test #30:
score: 0
Accepted
time: 1ms
memory: 7940kb
input:
100 98 99
output:
412293529
result:
ok 1 number(s): "412293529"