問題一覧 > 通常問題

No.2829 GCD Divination

レベル : / AI推定難易度 : 1600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-5}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 67
作問者 : twitteryou / テスター : 👑 p-adic
お気に入りにしたユーザー ProblemId : 11030 / 自分の提出
問題文最終更新日: 2024-08-04 08:20:12
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 439 (順位表) の他の問題:

Problem Statement

You are given an integer $N$. Repeat the following action until $N$ becomes $1$.
・Choose an integer $M$ between $1$ and $N$, inclusive, uniformly at random. Replace $N$ with $\ \gcd (N,M)\ $.
Find the expected number of actions until $N$ becomes $1$.

Input

$N$

・$2 \leq N \leq 10^7$
・$N$ is an integer.

Output

Output the expected number of actions. The answer may be a non-integer. Your answer is judged as correct if either its absolute error or its relative error, compared with the reference solution's output (which is computed so that its error from the true value is at most $10^{-10}$), is at most $10^{-5}$.

Sample

Sample 1
Input
2
Output
2

In each trial, $1$ comes up with probability $\frac{1}{2}$, giving $\gcd(1,2)=1\ $, and the process ends. The value to find is $\sum_{i=1}^{\infty}i2^{-i}$. This equals $2$.

Sample 2
Input
3
Output
1.5

Sample 3
Input
4
Output
2

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。