結果
問題 | 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 = 258280327def main():import sysinput = sys.stdin.read().split()ptr = 0n = int(input[ptr])ptr += 1f_coeffs = list(map(int, input[ptr:ptr + n + 1]))ptr += n + 1m = int(input[ptr])ptr += 1g_coeffs = list(map(int, input[ptr:ptr + m + 1]))ptr += m + 1# Mod each coefficientf = [x % MOD for x in f_coeffs]g = [x % MOD for x in g_coeffs]# Compute the productproduct_degree = n + mproduct = [0] * (product_degree + 1)for i in range(len(f)):a = f[i]if a == 0:continuefor j in range(len(g)):product[i + j] = (product[i + j] + a * g[j]) % MOD# Trim trailing zeros to find the actual degreedegree = product_degreewhile degree > 0 and product[degree] == 0:degree -= 1print(degree)print(' '.join(map(str, product[:degree + 1])))if __name__ == "__main__":main()