結果
問題 |
No.2369 Some Products
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:28:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 863 bytes |
コンパイル時間 | 281 ms |
コンパイル使用メモリ | 81,332 KB |
実行使用メモリ | 82,356 KB |
最終ジャッジ日時 | 2025-04-15 22:30:33 |
合計ジャッジ時間 | 4,233 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 1 TLE * 1 -- * 12 |
ソースコード
MOD = 998244353 def main(): import sys input = sys.stdin.read().split() ptr = 0 N = int(input[ptr]) ptr += 1 P = list(map(int, input[ptr:ptr+N])) ptr += N # Precompute modulo values P_mod = [x % MOD for x in P] Q = int(input[ptr]) ptr += 1 for _ in range(Q): A = int(input[ptr]) B = int(input[ptr+1]) K = int(input[ptr+2]) ptr +=3 # Convert to 0-based indices A -= 1 B -= 1 sub = P_mod[A:B+1] L = B - A + 1 if K > L: print(0) continue dp = [0] * (K+1) dp[0] = 1 for x in sub: # Iterate from K down to 1 for k in range(min(K, len(dp)-1), 0, -1): dp[k] = (dp[k] + dp[k-1] * x) % MOD print(dp[K] % MOD) if __name__ == "__main__": main()