atcoder#AGC032F. [AGC032F] One Third
[AGC032F] One Third
Score : points
Problem Statement
We have a round pizza. Snuke wants to eat one third of it, or something as close as possible to that.
He decides to cut this pizza as follows.
First, he divides the pizza into pieces by making cuts with a knife. The knife can make a cut along the segment connecting the center of the pizza and some point on the circumference of the pizza. However, he is very poor at handling knives, so the cuts are made at uniformly random angles, independent from each other.
Then, he chooses one or more consecutive pieces so that the total is as close as possible to one third of the pizza, and eat them. (Let the total be x of the pizza. He chooses consecutive pieces so that is minimized.)
Find the expected value of . It can be shown that this value is rational, and we ask you to print it modulo , as described in Notes.
Notes
When you print a rational number, first write it as a fraction , where are integers and is not divisible by (under the constraints of the problem, such representation is always possible). Then, you need to print the only integer between and , inclusive, that satisfies .
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the expected value of modulo , as described in Notes.
2
138888890
The expected value is .
3
179012347
The expected value is .
10
954859137
1000000
44679646