結果
| 問題 |
No.2369 Some Products
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-06 19:16:44 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 817 ms / 2,500 ms |
| コード長 | 1,287 bytes |
| コンパイル時間 | 2,162 ms |
| コンパイル使用メモリ | 163,416 KB |
| 実行使用メモリ | 394,496 KB |
| 最終ジャッジ日時 | 2025-02-06 19:16:56 |
| 合計ジャッジ時間 | 8,030 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 14 |
ソースコード
//Date: 2025-02-06 18:04:09
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define P emplace_back
#define CLEAR(a,v) memset(a,(v),sizeof(a))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
//char buf[1<<20],*p1,*p2;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
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 {
const int M=998244353;
int n,a[5005],f[5005][5005],g[5005][5005];
void MAIN() {
cin>>n;f[0][0]=g[0][0]=1;
rep(i,1,n) {
a[i]=(rd()%M+M)%M;
rep(j,0,n) f[i][j]=f[i-1][j],g[i][j]=g[i-1][j];
rep(j,1,n) f[i][j]=(f[i][j]+f[i-1][j-1]*a[i])%M;
rep(j,1,n) g[i][j]=(g[i][j]-g[i][j-1]*a[i]+M)%M;
}
for(int q=rd();q;q--) {
int l=rd(),r=rd(),k=rd(),ans=0;
rep(i,0,k) ans=(ans+f[r][i]*g[l-1][k-i])%M;
cout<<ans<<'\n';
}
}
}
bool MED;
signed main() {
//freopen(".in","r",stdin);freopen(".out","w",stdout);
for(int tt=1;tt;tt--) SOLVER::MAIN();
cerr<<(&MBE-&MED)/1024<<" KB, "<<1000*clock()/CLOCKS_PER_SEC<<" ms\n";
return 0;
}