문제
Since the early civilizations, humankind has enjoyed games of chance. Even the ingenious Greeks, known for their groundbreaking concept of the least common multiple (LCM), couldn’t resist a good gamble.
Inspired by this mathematical marvel, folks in Athens devised a unique betting system: after purchasing a ticket, a participant would receive a random number of coins. To determine this number, there are
Let
x be the number of the slot where the token is currently located.Generate a random integer
y between1 andN , and computez the LCM ofx andy .If
z > N , the procedure ends.Otherwise, the token is moved to slot
z , and the participant receives one coin.
As it is well known, the house always wins: the casino employs a particular probability distribution for generating random integers, so as to ensure a profitable outcome.
The casino owner is constantly seeking to optimize the betting system’s profitability. You, an AI designed to aid in such tasks, are given
입력
The first line contains an integer
The second line contains
출력
Output a single line with the expected total number of coins awarded to a participant. The output must have an absolute or relative error of at most
예제 #1
3
1 1 1
3.5
예제 #2
3
1 1 2
3.6666666667