結果

問題 No.2829 GCD Divination
ユーザー Shirotsume
提出日時 2024-08-02 21:54:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 623 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 82,376 KB
実行使用メモリ 72,984 KB
最終ジャッジ日時 2024-08-02 21:54:57
合計ジャッジ時間 2,870 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
import sys, time, random
from collections import deque, Counter, defaultdict
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 61 - 1
mod = 998244353

n = ii()
ni = 1 / n

@lru_cache(None)
def solve(x):
    if x == 1:
        return 0
    ans = 1
    for i in range(2, x + 1):
        if i * i > x:
            break
        if x % i == 0:
            ans += solve(x // i) / x
            if x // i != i:
                ans += solve(i) / x
    return ans * x / (x - 1)

print(solve(n))
        
0