結果
問題 |
No.2369 Some Products
|
ユーザー |
|
提出日時 | 2025-03-09 16:23:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 701 bytes |
コンパイル時間 | 1,896 ms |
コンパイル使用メモリ | 163,192 KB |
実行使用メモリ | 17,216 KB |
最終ジャッジ日時 | 2025-03-09 16:23:33 |
合計ジャッジ時間 | 6,443 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 1 TLE * 1 -- * 12 |
ソースコード
#include<bits/stdc++.h> using namespace std; const int N=5005,M=998244353; int qp(int a,int b){int s=1;while(b){if(b&1)s=s*a%M;a=a*a%M,b>>=1;}return s;} 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<=i;j++)c.f[i]=(c.f[i]+a.f[j]*b.f[i-j])%M; return c; } void operator*=(poly&a,poly b){ a=a*b; } int main(){ cin>>n; for(int i=1;i<=n;i++)cin>>p[i]; 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; }