QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#474413 | #2568. Mountains | lichenyu_ac | WA | 12ms | 21304kb | C++14 | 1.4kb | 2024-07-12 17:55:42 | 2024-07-12 17:55:47 |
Judging History
answer
#include<bits/stdc++.h>
#define ing long long
typedef long long ll;
using namespace std;
const int N=510,M=1e6+10,mod=1e9+7;
ll power(ll a,ll b){
ll ans=1;
for(;b;b>>=1){
if(b&1)ans=ans*a%mod;
a=a*a%mod;
}
return ans;
}
ll n,m,K;
ll A[N][N],f[M],incf[M];
void init(int len){
f[0]=1;
for(int i=1;i<=len;i++)f[i]=f[i-1]*i%mod;
incf[len]=power(f[len],mod-2);
for(int i=len-1;i>=0;i--)incf[i]=incf[i+1]*(i+1)%mod;
}
ll C(ll a,ll b){
if(a<b)return 0;
return f[a]*incf[b]%mod*incf[a-b]%mod;
}
ll Guess(){
ll ans=1;
for(int i=1;i<=n;i++){
if(!A[i][i]){
for(int j=i+1;j<=n;j++){
if(A[j][i]){
ans*=-1;
for(int k=1;k<=n;k++)
swap(A[i][k],A[j][k]);
break;
}
}
}
if(!A[i][i])return 0;
for(int j=i+1;j<=n;j++){
if(A[j][i]>A[i][i]){
ans*=-1;
for(int k=1;k<=n;k++)
swap(A[i][k],A[j][k]);
}
while(A[j][i]){
ll tmp=A[i][i]*power(A[j][i],mod-2)%mod;
for(int k=1;k<=n;k++)
A[i][k]=(A[i][k]-tmp*A[j][k]%mod+mod)%mod;
ans*=-1;
for(int k=1;k<=n;k++)
swap(A[i][k],A[j][k]);
}
for(int k=1;k<=n;k++)A[j][k]%=mod;
}
}
ans=(ans+mod)%mod;
for(int i=1;i<=n;i++)ans=(ans*A[i][i]%mod+mod)%mod;
return ans;
}
signed main(){
init(M-1);
scanf("%lld%lld%lld",&n,&m,&K);
for(int i=1;i<=K;i++)
for(int j=1;j<=K;j++){
ll x=n+(j-i),y=m-(j-i);
A[i][j]=C(x+y,x);
}
printf("%lld\n",Guess());
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 8ms
memory: 20596kb
input:
1 1 1
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 8ms
memory: 19748kb
input:
2 2 2
output:
20
result:
ok 1 number(s): "20"
Test #3:
score: -100
Wrong Answer
time: 12ms
memory: 21304kb
input:
2 3 4
output:
50
result:
wrong answer 1st numbers differ - expected: '490', found: '50'