結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-08-02 22:01:48 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 579 bytes |
| コンパイル時間 | 202 ms |
| コンパイル使用メモリ | 82,456 KB |
| 実行使用メモリ | 76,928 KB |
| 最終ジャッジ日時 | 2024-08-02 22:01:53 |
| 合計ジャッジ時間 | 3,849 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 RE * 29 |
ソースコード
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
from math import gcd
n = ii()
ni = 1 / n
@lru_cache(None)
def solve(x):
if x == 1:
return 0
ans = 1
for i in range(2, x):
ans += solve(gcd(x, i)) / x
return ans * x / (x - 1)
if n >= 1000000:
raise Exception("n is too large")
else:
print(solve(n))