Submission #3623495
Source Code Expand
// In the name of God #include<bits/stdc++.h> #define F first #define S second #define PB push_back #define sz(s) int((s).size()) #define bit(n,k) (((n)>>(k))&1) using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; const int maxn=4010,mod=998244353; const ll inf=1e18; int ans[maxn],fac[maxn],ifac[maxn],tw[maxn]; int Pow(int a,int b){ int ans=1; while(b){ if(b&1) ans=1ll*ans*a %mod; a=1ll*a*a %mod; b>>=1; } return ans; } inline int C(int n,int k){ if(n<k) return 0; return 1ll*fac[n]*ifac[k] %mod *ifac[n-k] %mod; } int solve(int n,int x){// x1+x2+x3+...+xn == x // xi>=0 return C(n+x-1,n-1); } int main(){ fac[0]=1; for(int i=1;i<maxn;i++) fac[i]=1ll*fac[i-1]*i %mod; ifac[maxn-1]=Pow(fac[maxn-1],mod-2); for(int i=maxn-2;i>=0;i--) ifac[i]=1ll*ifac[i+1]*(i+1) %mod; tw[0]=1; for(int i=1;i<maxn;i++) tw[i]=2ll*tw[i-1] %mod; int k,n;cin>>k>>n; for(int i=2;i<=k+1;i++){ int cnt=(i/2)-((i&1)==0); for(int j=0;j<=cnt;j++){ ans[i]=(1ll*ans[i]+1ll*C(cnt,j)*tw[j] %mod *(solve(k-2*(cnt-j)-j-((i&1)==0),n-j)+((i&1)?0:solve(k-2*(cnt-j)-j-1,n-j-1))))%mod; } } for(int i=2;i<=k+1;i++) cout<<ans[i]<<"\n"; for(int i=k;i>=2;i--) cout<<ans[i]<<"\n"; }
Submission Info
Submission Time | |
---|---|
Task | E - Stop. Otherwise... |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 700 |
Code Size | 1294 Byte |
Status | AC |
Exec Time | 37 ms |
Memory | 384 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 700 / 700 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 37 ms | 384 KB |
02.txt | AC | 30 ms | 384 KB |
03.txt | AC | 37 ms | 384 KB |
04.txt | AC | 1 ms | 256 KB |
05.txt | AC | 30 ms | 384 KB |
06.txt | AC | 30 ms | 384 KB |
07.txt | AC | 37 ms | 384 KB |
08.txt | AC | 6 ms | 256 KB |
09.txt | AC | 1 ms | 256 KB |
10.txt | AC | 17 ms | 384 KB |
11.txt | AC | 27 ms | 384 KB |
12.txt | AC | 1 ms | 256 KB |
13.txt | AC | 5 ms | 256 KB |
14.txt | AC | 33 ms | 384 KB |
15.txt | AC | 33 ms | 384 KB |
16.txt | AC | 29 ms | 384 KB |
17.txt | AC | 1 ms | 256 KB |
18.txt | AC | 1 ms | 256 KB |
19.txt | AC | 1 ms | 256 KB |
20.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |
s3.txt | AC | 1 ms | 256 KB |