QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501580#8047. DFS Order 4WilliamxzhCompile Error//C++231.1kb2024-08-02 21:00:182024-08-02 21:00:22

Judging History

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

  • [2024-08-02 21:00:22]
  • 评测
  • [2024-08-02 21:00:18]
  • 提交

answer

#include <bits/stdc++.h>
#define il inline
using namespace std;
typedef long long ll;ll mod;
il void add(ll &x,ll y){x=(x+y>=mod?x+y-mod:x+y);}
il void del(ll &x,ll y){x=(x<y?x-y+mod:x-y);}
il ll qp(ll a,ll b){
    ll ans=1ll;
    while(b){
        if(b&1) ans=(ans*a)%mod;
        a=(a*a)%mod,b>>=1;
    }return ans;
}
const int N=803;
int n;ll f[N][N],fac[N],inv[N];
il void init(){
    fac[0]=1ll;for(int i=1;i<=n;++i) fac[i]=(fac[i-1]*1ll*i)%mod;
    for(int i=1;i<=n;++i) inv[i]=qp(i,mod-2ll);
}
int main(){
    //freopen("qoj8047_0.in","r",stdin);
    scanf("%d%lld",&n,&mod);init();if(n<=1){printf("1");exit(0);}
    f[1][0]=1ll;
    for(int i=2;i<n;++i)
        for(int k=0;k<=i;++k){
            f[i][k]=f[i-1][k+1]
            if(!k) add(f[i][0],f[i-1][0]);
            for(int j=1;j<=i-k;++j){
                add(f[i][k],f[j-1][0]*f[i-j][k]%mod);
                if(k) del(f[i][k],(f[j-1][0]+(j==1))*f[i-j][k-1]%mod);
            }
            f[i][k]=(f[i][k]*inv[i])%mod;
        }

    printf("%lld",f[n-1][0]*fac[n-1]%mod);
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:26:32: error: expected ‘;’ before ‘if’
   26 |             f[i][k]=f[i-1][k+1]
      |                                ^
      |                                ;
   27 |             if(!k) add(f[i][0],f[i-1][0]);
      |             ~~                  
answer.code:22:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   22 |     scanf("%d%lld",&n,&mod);init();if(n<=1){printf("1");exit(0);}
      |     ~~~~~^~~~~~~~~~~~~~~~~~