結果
問題 | No.2369 Some Products |
ユーザー |
|
提出日時 | 2024-12-28 20:59:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 408 ms / 2,500 ms |
コード長 | 755 bytes |
コンパイル時間 | 2,152 ms |
コンパイル使用メモリ | 192,980 KB |
最終ジャッジ日時 | 2025-02-26 17:06:16 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:12:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:14:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 14 | scanf("%d", &a[i]); | ~~~~~^~~~~~~~~~~~~ main.cpp:25:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 25 | scanf("%d", &m); | ~~~~~^~~~~~~~~~ main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 28 | scanf("%d%d%d", &l, &r, &k); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using LL = long long; const int N = 5e3 + 7; const int MOD = 998244353; int a[N], f[N][N], g[N][N], n, m; int main() { scanf("%d", &n); for(int i = 1; i <= n; ++i) scanf("%d", &a[i]); f[0][0] = g[0][0] = 1; for(int i = 1; i <= n; ++i) { f[i][0] = g[i][0] = 1; for(int j = n; j >= 1; --j) f[i][j] = (f[i - 1][j] + 1LL * a[i] * f[i - 1][j - 1]) % MOD; for(int j = 0; j < n; ++j) g[i][j + 1] = (g[i - 1][j + 1] - 1LL * a[i] * g[i][j]) % MOD; } scanf("%d", &m); while(m--) { int ans = 0, l, r, k; scanf("%d%d%d", &l, &r, &k); for(int i = 0; i <= k; ++i) ans = (ans + 1LL * f[r][i] * g[l - 1][k - i]) % MOD; printf("%d\n", (ans + MOD) % MOD); } return 0; }