結果
問題 |
No.2829 GCD Divination
|
ユーザー |
![]() |
提出日時 | 2024-08-03 11:14:37 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 358 ms |
コンパイル使用メモリ | 82,920 KB |
実行使用メモリ | 648,672 KB |
最終ジャッジ日時 | 2024-08-03 11:14:42 |
合計ジャッジ時間 | 4,369 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 MLE * 1 -- * 30 |
ソースコード
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) S = set() for d in reversed(D[1:]): i = 1 while i * d <= N: if i * d not in S: S.add(i * d) dic[d] += 1 i += 1 dic[1] = N - 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))