結果
問題 |
No.2187 三立法和 mod 333
|
ユーザー |
![]() |
提出日時 | 2025-06-12 21:41:45 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,002 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 82,688 KB |
最終ジャッジ日時 | 2025-06-12 21:45:36 |
合計ジャッジ時間 | 14,143 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | TLE * 33 |
ソースコード
from bisect import bisect_right A = int(input()) K = 4444 ** 4 # Precompute residue_dict residue_dict = {r: [] for r in range(333)} for y in range(1, 4445): r = pow(y, 3, 333) y4 = y ** 4 residue_dict[r].append(y4) # Sort each list for r in residue_dict: residue_dict[r].sort() total = 0 for x in range(1, 4445): r_x = pow(x, 3, 333) T = (A - r_x) % 333 x4 = x ** 4 M = K - x4 if M < 0: continue for a in range(333): b = (T - a) % 333 if a not in residue_dict or b not in residue_dict: continue list_a = residue_dict[a] list_b = residue_dict[b] for y4 in list_a: if y4 > M: break remaining = M - y4 if remaining < 0: continue if remaining < 1: continue # Find number of z4 in list_b <= remaining count = bisect_right(list_b, remaining) total += count print(total)