結果
問題 |
No.2510 Six Cube Sum Counting
|
ユーザー |
|
提出日時 | 2025-01-08 00:52:18 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 938 bytes |
コンパイル時間 | 1,171 ms |
コンパイル使用メモリ | 82,624 KB |
実行使用メモリ | 558,424 KB |
最終ジャッジ日時 | 2025-01-08 00:54:57 |
合計ジャッジ時間 | 157,514 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | MLE * 4 |
other | MLE * 26 |
ソースコード
x = int(input()) m = 301 from collections import Counter import itertools as it import bisect as bs lcs = [Counter(a**3 + b**3 for a, b in it.combinations_with_replacement(range(c + 1), 2)) for c in range(m)] rds = [Counter(e**3 + f**3 for e, f in it.combinations_with_replacement(range(d, m), 2)) for d in range(m)] lcs_ = [sorted(c.items()) for c in lcs] rds_ = [sorted(c.items()) for c in rds] ans = 0 for c, d in it.combinations_with_replacement(range(m), 2): rem = x - c**3 - d**3 if rem < d**3 * 2: continue lc = lcs[c] rd = rds[d] lc_ = lcs_[c] rd_ = rds_[d] il = bs.bisect_right(lc_, rem - d**3 * 2, key=lambda t: t[0]) ir = bs.bisect_right(rd_, rem, key=lambda t: t[0]) if il < ir: for i in range(il): s, f = lc_[i] ans += f * rd[rem - s] else: for i in range(ir): s, f = rd_[i] ans += f * lc[rem - s] print(ans)