結果

問題 No.3296 81-like number
コンテスト
ユーザー Hyoka7
提出日時 2025-10-05 15:47:00
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 73 ms / 2,000 ms
+ 220µs
コード長 703 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 243 ms
コンパイル使用メモリ 95,972 KB
実行使用メモリ 84,608 KB
最終ジャッジ日時 2026-07-15 13:19:16
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def readint():
    return map(int, input().split())


def sieve(n):
    isprime = [True] * (n + 1)
    res = []
    isprime[0] = isprime[1] = False
    for i in range(2, n + 1):
        if not isprime[i]:
            continue
        else:
            res.append(i)
            for j in range(i * i, n + 1, i):
                isprime[j] = False
    return res


from math import isqrt

n = int(input())
p = sieve(isqrt(n))
ans = 0
for i in range(len(p)):
    syoko = p[i] * p[i]
    if syoko > n:
        break
    makko = syoko
    kosu = 1
    while makko <= n:
        makko *= p[i]
        kosu += 1
    makko //= p[i]
    kosu -= 1
    ans += (syoko * (p[i] ** kosu - 1)) // (p[i] - 1)
print(ans)
0