結果

問題 No.2510 Six Cube Sum Counting
ユーザー amentorimaru
提出日時 2023-09-22 19:51:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,573 ms / 4,000 ms
コード長 595 bytes
コンパイル時間 423 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 392,644 KB
最終ジャッジ日時 2024-09-19 12:52:22
合計ジャッジ時間 70,127 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
n = int(input())
if n==0:
    print(1)
    exit()
ans = 0
cubes = {}
for a in range(301):
	a3 = a * a * a
	for b in range(a, 301):
		b3 = b * b * b
		for c in range(b, 301):
			c3 = c * c * c
			x = a3 + b3 + c3
			y = (a << 18) | (b << 9) | c
			cubes[x] = (cubes.get(x,0) << 27) | y
for x, tw in cubes.items():
	z = n - x
	w1 = tw
	if not z in cubes:
		continue
	while w1:
		z = n - x
		w2 = cubes[z]
		while w2:
			if w2 & 0x1ff <= (w1 >> 18) & 0x1ff:
				ans += 1
			w2 >>= 27
		w1 >>= 27
					
w = cubes.get(n,0)
while w:
	ans += 1
	w >>= 27
print(ans)
0