QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#476623 | #2568. Mountains | DEMONKILLER | WA | 0ms | 3964kb | C++14 | 1.3kb | 2024-07-13 20:31:20 | 2024-07-13 20:31:20 |
Judging History
answer
#include<bits/stdc++.h>
#define N 310
#define mod 1000000007
using namespace std;
int n,m,K,res=1,g[N][N];
long long fac[N],inv[N];
long long qpow(long long a,int b){
long long Res=1;
while(b){
if(b&1)Res=Res*a%mod;
a=a*a%mod;
b>>=1;
}
return Res;
}
long long c(int a,int b){
return fac[a]*inv[b]%mod*inv[a-b]%mod;
}
int main(){
scanf("%d%d%d",&n,&m,&K);
fac[0]=fac[1]=1;
for(int i=2;i<=N-10;i++)fac[i]=fac[i-1]*i%mod;
inv[N-10]=qpow(fac[N-10],mod-2);
for(int i=N-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
for(int i=1;i<=K;i++)
for(int j=1;j<=K;j++)
g[i][j]=c(n+m,m+j-i);
for(int i=1;i<=K;i++){
int v=K+1;
for(int j=i;j<=K;j++){
if(g[j][i]){
v=j;
break;
}
}
if(v==K+1){
res=0;
break;
}
if(v!=i){
swap(g[v],g[i]);
res=mod-res;
}
int inv=qpow(g[i][i],mod-2);
for(int j=i+1;j<=K;j++){
int mul=1ll*g[j][i]*inv%mod;
for(int k=i;k<=K;k++)
g[j][k]=(g[j][k]-1ll*g[i][k]*mul%mod+mod)%mod;
}
res=1ll*res*g[i][i]%mod;
}
printf("%d",res);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3740kb
input:
1 1 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3880kb
input:
2 2 2
output:
20
result:
ok 1 number(s): "20"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3824kb
input:
2 3 4
output:
490
result:
ok 1 number(s): "490"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3964kb
input:
1 2 8
output:
299404809
result:
wrong answer 1st numbers differ - expected: '45', found: '299404809'