QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476623#2568. MountainsDEMONKILLERWA 0ms3964kbC++141.3kb2024-07-13 20:31:202024-07-13 20:31:20

Judging History

你现在查看的是最新测评结果

  • [2024-07-13 20:31:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3964kb
  • [2024-07-13 20:31:20]
  • 提交

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);
}

詳細信息

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'