結果

問題 No.3296 81-like number
ユーザー Hyoka7
提出日時 2025-10-05 15:47:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 64,280 KB
最終ジャッジ日時 2025-10-05 15:47:04
合計ジャッジ時間 1,727 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

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