結果

問題 No.3332 Consecutive Power Sum (Small)
コンテスト
ユーザー 遭難者
提出日時 2025-11-02 22:27:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 177 ms / 2,025 ms
コード長 618 bytes
コンパイル時間 406 ms
コンパイル使用メモリ 82,712 KB
実行使用メモリ 146,500 KB
最終ジャッジ日時 2025-11-02 22:28:49
合計ジャッジ時間 7,791 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
e = 2
ans = []
m = 2 * n
c = 1
while c * c <= m:
    if m % c == 0:
        x, y = c, m // c
        if (x + y) % 2 == 1:
            l, r = (y - x - 1) // 2, (y + x - 1) // 2
            ans.append((1, l + 1, r))
    c += 1
while True:
    if 2**e - 1 > n:
        break
    a = [0, 1]
    while a[-1] - a[-2] < n:
        a.append(a[-1] + len(a) ** e)
    j = 0
    for i in range(len(a)):
        while j != len(a) and a[j] < a[i] - n:
            j += 1
        if a[j] == a[i] - n:
            ans.append((e, j + 1, i))
    e += 1
ans.sort()
print(len(ans))
for e, j, i in ans:
    print(e, j, i)
0