結果

問題 No.2510 Six Cube Sum Counting
ユーザー なえしら
提出日時 2023-10-20 22:48:57
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 506 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 859,328 KB
最終ジャッジ日時 2024-09-20 20:55:10
合計ジャッジ時間 6,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 MLE * 1 -- * 1
other -- * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from itertools import combinations_with_replacement

X = int(input())
C = defaultdict(list)
D = defaultdict(list)
for a, b, c in combinations_with_replacement(range(301), 3):
  x = a**3 + b**3 + c**3
  if 2 * x <= X:
    C[x].append(c)
  elif x <= X:
    D[x].append(a)
cnt = 0
for x in C:
  if 2 * x > X: break
  y = X - x
  C[x].sort()
  j = 0
  for i in range(len(C[x])):
    while j < len(D[y]) and D[y][j] < C[x][i]:
      j += 1
    cnt += len(D[y]) - j
print(cnt)
0