結果

問題 No.2829 GCD Divination
ユーザー ntudantuda
提出日時 2024-08-03 11:47:11
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 780 bytes
コンパイル時間 461 ms
コンパイル使用メモリ 82,924 KB
実行使用メモリ 89,712 KB
最終ジャッジ日時 2024-08-03 11:47:18
合計ジャッジ時間 7,069 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
61,400 KB
testcase_01 AC 41 ms
53,996 KB
testcase_02 AC 43 ms
60,400 KB
testcase_03 AC 38 ms
55,148 KB
testcase_04 TLE -
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def make_divisors(n):
    divisors = []
    i = 1
    while i ** 2 <= n:
        if n % i == 0:
            divisors.append(i)
            if i ** 2 != n:
                divisors.append(n // i)
        i += 1
    divisors.sort()
    return divisors

def f(x):
    if x == 1:
        return 0
    P = (x / (x - 1)) ** 2
    D = make_divisors(x)
    dic = defaultdict(int)

    for d in reversed(D):
        tmp = x // d
        for d2 in reversed(D):
            if d == d2:
                break
            if d2 % d == 0:
                tmp -= dic[d2]
        dic[d] = tmp

    dic[1] = d - sum(dic.values())
    ret = 0
    for d in D[:-1]:
        ret += f(d) / x * dic[d]
    return (ret + 1) * x / (x - 1)

N = int(input())
print(f(N))
0