結果
| 問題 |
No.3331 Consecutive Cubic Sum
|
| コンテスト | |
| ユーザー |
kokonotsu
|
| 提出日時 | 2025-11-02 21:52:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 2,664 ms / 5,000 ms |
| コード長 | 823 bytes |
| コンパイル時間 | 455 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 77,632 KB |
| 最終ジャッジ日時 | 2025-11-02 21:54:37 |
| 合計ジャッジ時間 | 55,895 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 47 |
ソースコード
from math import isqrt
def isOK(mid, key):
q = key // mid
if q > mid:
return True
else:
return False
def bi_search(key):
ok = -1
ng = 10 ** 18
while abs(ok - ng) > 1:
mid = (ok + ng) // 2
if isOK(mid, key):
ok = mid
else:
ng = mid
return ok
N = int(input())
C = 0
ans = []
s = 0
for l in range(1, 10 ** 6 + 1):
p = l ** 3
if p > N:
break
elif p == N:
C += 1
ans.append((l, l))
break
else:
s += l - 1
x = N + s ** 2
x_sqrt = isqrt(x)
if x == x_sqrt ** 2:
r = bi_search(2 * x_sqrt)
if r * (r + 1) == 2 * x_sqrt:
C += 1
ans.append((l, r))
print(C)
ans.sort()
for a in ans:
print(*a)
kokonotsu