QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#426499#6325. Peaceful Resultsby_chanceCompile Error//C++172.3kb2024-05-31 13:02:432024-05-31 13:02:44

Judging History

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

  • [2024-05-31 13:02:44]
  • 评测
  • [2024-05-31 13:02:43]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=4e6+5,P=998244353;
inline void pls(int&a,int b){a+=b;if(a>=P)a-=P;}
int qpow(int a,int b=P-2){
    int c=1;
    for(;b;b>>=1,a=1ll*a*a%P)
        if(b&1)c=1ll*c*a%P;
    return c;
}
int n,fac[N],ifac[N],inv[N];
int a[15],b[15],flag;
int f[N],g[N],h[N],rev[N],_G[N],invG[N];
int ask(int i){if(i>=0&&i<N)return ifac[i];else return 0;}
void NTT(int*f,int n,int op){
    for(int i=0;i<n;++i)if(i<rev[i])swap(f[i],f[rev[i]]);
    for(int p=2;p<=n;p<<=1){
        int len=p>>1,tG=(op==1?_G[p]:invG[p]);
        for(int k=0;k<n;k+=p){
            int buf=1;
            for(int l=k;l<k+len;++l){
                int tmp=1ll*f[l+len]*buf%P;f[l+len]=f[l];
                pls(f[l+len],P-tmp);pls(f[l],tmp);buf=1ll*buf*tG%P;
            }
        }
    }
    if(op==-1){
        for(int i=0;i<n;++i)
            f[i]=1ll*f[i]*inv[n]%P;
    }
}
void times(int*f,int*g,int m){
    int n=1;for(;n<=2*m;n<<=1);for(int i=m;i<n;++i)f[i]=g[i]=0;
    for(int i=0;i<n;++i)rev[i]=(rev[i>>1]>>1)|((i&1)?(n>>1):0);
    NTT(f,n,1);NTT(g,n,1);for(int i=0;i<n;++i)f[i]=1ll*f[i]*g[i]%P;
    NTT(f,n,-1);for(int i=m;i<n;++i)f[i]=0;
}
void init(){
    fac[0]=ifac[0]=inv[1]=1;
    for(int i=1;i<N;++i)fac[i]=1ll*fac[i-1]*i%P;
    for(int i=2;i<N;++i)inv[i]=1ll*(P-P/i)*inv[P%i]%P;
    for(int i=1;i<N;++i)ifac[i]=1ll*ifac[i-1]*inv[i]%P;
    for(int i=1;i<N;i<<=1)_G[i]=qpow(3,(P-1)/i),invG[i]=qpow((P+1)/3,(P-1)/i);    
}
int main(){
    init();scanf("%d",&n);flag=1;
    for(int i=1;i<=9;++i)scanf("%d",a+i);
    b[1]=-a[1]-2*a[2]+2*a[4]+a[5]+2*a[7]+a[8];
    b[2]=-2*a[1]-a[2]+a[4]+2*a[5]+a[7]+2*a[8];b[3]=a[3];
    b[4]=2*a[1]+a[2]-a[4]+a[5]-a[7]-2*a[8];
    b[5]=2*a[1]+a[2]-a[4]-2*a[5]-a[7]+a[8];
    b[6]=a[1]+2*a[2]+a[4]-a[5]-2*a[7]-a[8];
    b[7]=a[1]+2*a[2]-2*a[4]-a[5]+a[7]-a[8];
    for(int i:{1,2,4,5,6,7}){if(b[i]%3==0)b[i]/=3;else flag=0;}
    if(!flag){printf("0\n");continue;}
    for(int i=0;i<=n;++i){
        f[i]=1ll*ask(b[1]-n+i)*ask(b[2]-n+i)%P*ask(b[3]-n+i)%P;
        g[i]=1ll*ask(b[4]+i)*ask(b[7]+i)%P*ask(b[9]+i)%P;
        h[i]=1ll*ask(b[5]+i)*ask(b[6]+i)%P*ask(b[8]+i)%P;
    }
    times(f,g,n+1);int ans=0;
    for(int i=0;i<=n;i++)ans=(ans+1ll*f[i]*h[n-i]%P)%P;
    printf("%lld\n",1ll*fac[n]*ans%P);
    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:55:29: error: continue statement not within a loop
   55 |     if(!flag){printf("0\n");continue;}
      |                             ^~~~~~~~
answer.code:46:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   46 |     init();scanf("%d",&n);flag=1;
      |            ~~~~~^~~~~~~~~
answer.code:47:31: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   47 |     for(int i=1;i<=9;++i)scanf("%d",a+i);
      |                          ~~~~~^~~~~~~~~~