luogu#P8307. 〈 TREEのOI 2022 Spring 〉Absolutely Simple Game
〈 TREEのOI 2022 Spring 〉Absolutely Simple Game
Background
rin and len are playing an absolutely simple game, and pcq is the referee.
Problem Description
Initially, the range is given. pcq uniformly randomly selects a natural number from it. Then rin and len take turns to operate, with rin moving first.
On each turn, the current player guesses an integer . If , the game ends and the current player loses. If , update the range to . If , update the range to .
Both rin and len fully understand the rules and are extremely cute and smart (they will both maximize their own winning probability). During the game, everyone knows all information on the table except . Find rin's winning probability.
Input Format
One line with one integer .
Output Format
One line with one integer, representing rin's winning probability, output the fraction .
3
665496236
Hint
Sample Explanation 1:
rin's winning probability is (guess at the beginning). After taking , the output is .
This problem uses bundled SubTask testing.
| SubTask ID | Score | Special Constraints |
|---|---|---|
For of the testdata, .
How to take a rational number modulo?
is defined as .
must be a prime.
It is guaranteed that, after reducing the fraction, the denominator is not a multiple of .
Translated by ChatGPT 5