QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#634374#9451. Expected Waiting Timeucup-team4770#WA 3ms18164kbC++171.5kb2024-10-12 17:10:442024-10-12 17:10:44

Judging History

This is the latest submission verdict.

  • [2024-10-12 17:10:44]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 18164kb
  • [2024-10-12 17:10:44]
  • Submitted

answer

//Date: 2024-10-12 16:55:31
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int rd() {
    int s=0,m=0;char ch=getchar();
    while(!isdigit(ch)) {if(ch=='-')m=1;ch=getchar();}
    while( isdigit(ch)) s=(s<<3)+(s<<1)+(ch^48),ch=getchar();
    return m?-s:s;
}
bool MBE;
namespace SOLVER {
int inv[2000005],ifr[2000005],fr[2000005],cat[2000005];
int n,M,b0,A,B,a[2000005],b[2000005],x[2000005],y[2000005],ans;
int C(int n,int m) {return n<m||m<0?0:fr[n]*ifr[m]%M*ifr[n-m]%M;}
int qpow(int x,int y) {int s=1;for(;y;y>>=1,x=x*x%M) if(y&1) s=s*x%M;return s;}
void MAIN() {
    cin>>n>>M>>b[0]>>A>>B;
    for(int i=0;i<=n*2+1;i++) inv[i]=fr[i]=inv[i]=cat[i]=a[i]=b[i]=x[i]=y[i]=0;
    inv[1]=1;fr[0]=1,ifr[0]=1;ans=0;
    for(int i=2;i<=n*2;i++) inv[i]=(M-M/i*inv[M%i]%M)%M;
    for(int i=1;i<=n*2;i++) fr[i]=fr[i-1]*i%M,ifr[i]=ifr[i-1]*inv[i]%M;
    for(int i=0;i<=n*2;i++) cat[i]=(C(i*2,i)-C(i*2,i-1)+M)%M;
    for(int i=1;i<=n*2;i++) b[i]=(A*b[i-1]+B)%M,a[i]=(a[i-1]+b[i]+1)%M;
    for(int i=2;i<=n*2;i++) if(i%2==0) y[i]=cat[n-i/2]*cat[i/2-1]%M;
    for(int i=1;i<=n*2;i++) y[i]=(y[i]+y[i-1])%M;
    for(int i=1;i<=n*2;i++) x[i]=y[n*2-i+1];
    for(int i=1;i<=n*2;i++) ans=(ans-a[i]*x[i]%M+a[i]*y[i]%M+M)%M;
    ans=ans*qpow((C(n*2,n)-C(n*2,n-1)+M)%M,M-2)%M;
    printf("%lld\n",(ans%M+M)%M);
}
}
bool MED;
signed main() {
    //freopen(".in","r",stdin);freopen(".out","w",stdout);
    for(int tt=rd();tt;tt--) SOLVER::MAIN();
    cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 3ms
memory: 18164kb

input:

5
1 1000000007 0 1 0
2 1000000007 0 1 1
2 7 5 2 3
3 31 15 6 24
20 1000000007 0 1 0

output:

1
12
1
10
879705565

result:

wrong answer 4th numbers differ - expected: '21', found: '10'