AtCoder Grand Contest 032
F
One Third
AtCoder
⌀ 3975
原题
← E→
翻译中…

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 $N$ pieces by making $N$ 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 $|x - 1/3|$ is minimized.)

翻译中…

Find the expected value of $|x - 1/3|$. It can be shown that this value is rational, and we ask you to print it modulo $10^9 + 7$, as described in Notes.

翻译中…

Note

翻译中…

When you print a rational number, first write it as a fraction $\frac{y}{x}$, where $x, y$ are integers and $x$ is not divisible by $10^9 + 7$ (under the constraints of the problem, such representation is always possible). Then, you need to print the only integer $z$ between $0$ and $10^9 + 6$, inclusive, that satisfies $xz \equiv y \pmod{10^9 + 7}$.

翻译中…

Constraints

翻译中…
  • $2 \leq N \leq 10^6$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N

翻译中…

Output

翻译中…

Print the expected value of $|x - 1/3|$ modulo $10^9 + 7$, as described in Notes.

翻译中…

样例

Input #1
2
Output #1
138888890
The expected value is $\frac{5}{36}$.
Input #2
3
Output #2
179012347
The expected value is $\frac{11}{162}$.
Input #3
10
Output #3
954859137
Input #4
1000000
Output #4
44679646
题目信息
题号
agc032_f
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。