結果
| 問題 | No.2829 GCD Divination |
| コンテスト | |
| ユーザー |
ニックネーム
|
| 提出日時 | 2024-08-02 22:24:12 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ac-library) |
| 結果 |
AC
不安定
|
| 実行時間 | 205 ms / 2,000 ms |
| + 521µs | |
| コード長 | 427 bytes |
| 記録 | |
| コンパイル時間 | 756 ms |
| コンパイル使用メモリ | 21,540 KB |
| 実行使用メモリ | 15,992 KB |
| 最終ジャッジ日時 | 2026-08-24 19:20:21 |
| 合計ジャッジ時間 | 6,915 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
from functools import cache
@cache
def f(n):
if n==1: return 0
s = set(); d = {}; x = 0
for i in range(1,int(n**0.5)+1):
if n%i==0: s |= {i,n//i}
s.remove(n); s = sorted(s); m = len(s)
for i in range(m-1,-1,-1):
d[s[i]] = (n-1)//s[i]
for j in range(i+1,m):
if s[j]%s[i]==0: d[s[i]] -= d[s[j]]
x += d[s[i]]*f(s[i])
return (x/n+1)*n/(n-1)
print(f(int(input())))
ニックネーム