QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#476645#2568. MountainsDEMONKILLERCompile Error//C++231.3kb2024-07-13 20:36:112024-07-13 20:36:11

Judging History

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

  • [2024-07-13 20:36:11]
  • 评测
  • [2024-07-13 20:36:11]
  • 提交

answer

#include<bits/stdc++.h>
#define N 310
#define mod 1000000007
using namespace std;
int n,m,K;
long long fac[N],inv[N],g[N][N];
long long res=1,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++){
            long long mul=g[j][i]*inv%mod;
            for(int k=i;k<=K;k++)
                g[j][k]=(g[j][k]-g[i][k]*mul%mod+mod)%mod;
        }
        res=res*g[i][i]%mod;
    }
    printf("%d",res);
}

详细

answer.code:7:40: error: a function-definition is not allowed here before ‘{’ token
    7 | long long res=1,qpow(long long a,int b){
      |                                        ^
answer.code: In function ‘int main()’:
answer.code:23:15: error: ‘qpow’ was not declared in this scope; did you mean ‘pow’?
   23 |     inv[N-10]=qpow(fac[N-10],mod-2);
      |               ^~~~
      |               pow
answer.code:52:14: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
   52 |     printf("%d",res);
      |             ~^  ~~~
      |              |  |
      |              |  long long int
      |              int
      |             %lld
answer.code:20:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |     scanf("%d%d%d",&n,&m,&K);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~