結果
問題 |
No.2272 多項式乗算 mod 258280327
|
ユーザー |
![]() |
提出日時 | 2025-03-20 21:08:43 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 972 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 82,312 KB |
実行使用メモリ | 70,164 KB |
最終ジャッジ日時 | 2025-03-20 21:09:37 |
合計ジャッジ時間 | 6,558 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 3 TLE * 1 -- * 5 |
ソースコード
MOD = 258280327 def main(): import sys input = sys.stdin.read().split() ptr = 0 n = int(input[ptr]) ptr += 1 f_coeffs = list(map(int, input[ptr:ptr + n + 1])) ptr += n + 1 m = int(input[ptr]) ptr += 1 g_coeffs = list(map(int, input[ptr:ptr + m + 1])) ptr += m + 1 # Mod each coefficient f = [x % MOD for x in f_coeffs] g = [x % MOD for x in g_coeffs] # Compute the product product_degree = n + m product = [0] * (product_degree + 1) for i in range(len(f)): a = f[i] if a == 0: continue for j in range(len(g)): product[i + j] = (product[i + j] + a * g[j]) % MOD # Trim trailing zeros to find the actual degree degree = product_degree while degree > 0 and product[degree] == 0: degree -= 1 print(degree) print(' '.join(map(str, product[:degree + 1]))) if __name__ == "__main__": main()