結果
問題 |
No.2369 Some Products
|
ユーザー |
|
提出日時 | 2025-03-09 16:26:53 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 677 bytes |
コンパイル時間 | 1,887 ms |
コンパイル使用メモリ | 161,708 KB |
実行使用メモリ | 11,808 KB |
最終ジャッジ日時 | 2025-03-09 16:26:59 |
合計ジャッジ時間 | 6,126 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 TLE * 1 -- * 12 |
ソースコード
#include<bits/stdc++.h> #define int long long using namespace std; const int N=5005,M=998244353; int n,q,p[N],a,b,k; struct poly{ int n,f[N]; void clear(){memset(f,0,sizeof f);} poly(){clear();} }ans,other; poly operator*(poly a,poly b){ poly c; c.n=min(a.n+b.n,k); for(int i=0;i<=c.n;i++)for(int j=0;j<=min(i,b.n);j++)c.f[i]=(c.f[i]+a.f[i-j]*b.f[j]%M)%M; return c; } void operator*=(poly&a,poly b){ a=a*b; } signed main(){ cin>>n; for(int i=1;i<=n;i++)cin>>p[i],p[i]=(p[i]%M+M)%M; cin>>q; while(q--){ cin>>a>>b>>k; ans.clear();ans.n=k,ans.f[0]=1; for(int i=a;i<=b;i++)other.n=1,other.f[0]=1,other.f[1]=p[i],ans*=other; cout<<ans.f[k]<<'\n'; } return 0; }