QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#321820 | #8171. Cola | grass8cow | WA | 1ms | 5900kb | C++17 | 759b | 2024-02-05 17:16:58 | 2024-02-05 17:16:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,m,jc[10010000],ij[10010000];
const int mod=998244353;
int qpow(int a,int b){
int c=1;
for(;b;b>>=1){
if(b&1)c=1ll*a*c%mod;
a=1ll*a*a%mod;
}
return c;
}
int C(int a,int b){if(a<0||b<0||a<b)return 0;return 1ll*jc[a]*ij[b]%mod*ij[a-b]%mod;}
int Z(int x){
if(x<0)return 0;
return C(x+n,n);
}
int main(){
scanf("%d%d",&n,&m);m--;
jc[0]=1;int O=n*2;
for(int i=1;i<=O;i++)jc[i]=1ll*i*jc[i-1]%mod;
ij[O]=qpow(jc[O],mod-2);
for(int i=O;i;i--)ij[i-1]=1ll*i*ij[i]%mod;
int ans=Z(m);
for(int k=1;k*(k*3-1)/2<=m;k++){
(ans+=((k&1)?-1:1)*Z(m-k*(k*3-1)/2))%=mod;
(ans+=((k&1)?-1:1)*Z(m-k*(k*3+1)/2))%=mod;
}
//(1-x-x^2+x^5+x^7-)
return printf("%d",(ans+mod)%mod),0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5900kb
input:
2 1
output:
1
result:
wrong answer 1st words differ - expected: '499122177', found: '1'