311033: CF1924C. Fractal Origami

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

C. Fractal Origamitime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You have a square piece of paper with a side length equal to $1$ unit. In one operation, you fold each corner of the square to the center of the paper, thus forming another square with a side length equal to $\dfrac{1}{\sqrt{2}}$ units. By taking this square as a new square, you do the operation again and repeat this process a total of $N$ times.

Performing operations for $N = 2$.

After performing the set of operations, you open the paper with the same side up you started with and see some crease lines on it. Every crease line is one of two types: a mountain or a valley. A mountain is when the paper folds outward, and a valley is when the paper folds inward.

You calculate the sum of the length of all mountain crease lines on the paper and call it $M$. Similarly, you calculate for valley crease lines and call it $V$. You want to find the value of $\dfrac{M}{V}$.

It can be proved that this value can be represented in the form of $A + B\sqrt{2}$, where $A$ and $B$ are rational numbers. Let this $B$ be represented as an irreducible fraction $\dfrac{p}{q}$, your task is to print $p*inv(q)$ modulo $999\,999\,893$ (note the unusual modulo), where $inv(q)$ is the modular inverse of $q$.

Input

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \leq t \leq 10^4$). Description of the test cases follows.

The only line of each test case contains an integer $N$ ($1 \leq N \leq 10^9$), the number of operations you perform on the square paper.

Output

For each test case, print on a new line the required answer.

ExampleInput
3
1
2
3
Output
0
1
714285638
Note

The blue lines in the given figures represent mountain crease lines, and the green lines represent valley crease lines.

Crease lines after $1$ operation $(\dfrac{M}{V} = 0)$.Crease lines after $2$ operations $(\dfrac{M}{V} = \sqrt{2} - 1)$.

Output

题目大意:你有一张边长为1单位的正方形纸。每次操作,你将正方形的每个角对折到纸张中心,形成一个边长为$\frac{1}{\sqrt{2}}$单位的新正方形,并重复此过程共N次。对折结束后,你展开纸张并计算所有山折痕(向外折叠)和谷折痕(向内折叠)的总长度,分别记为M和V,求$\frac{M}{V}$的值。这个值可以表示为$A + B\sqrt{2}$的形式,其中B为最简分数$\frac{p}{q}$,要求输出$p \times inv(q) \mod 999,999,893$的值,其中$inv(q)$是q的模逆元。

输入数据格式:第一行包含一个整数t($1 \leq t \leq 10^4$),表示测试用例的数量。接下来t行,每行包含一个整数N($1 \leq N \leq 10^9$),表示对正方形纸进行的操作次数。

输出数据格式:对于每个测试用例,输出一行要求的答案。题目大意:你有一张边长为1单位的正方形纸。每次操作,你将正方形的每个角对折到纸张中心,形成一个边长为$\frac{1}{\sqrt{2}}$单位的新正方形,并重复此过程共N次。对折结束后,你展开纸张并计算所有山折痕(向外折叠)和谷折痕(向内折叠)的总长度,分别记为M和V,求$\frac{M}{V}$的值。这个值可以表示为$A + B\sqrt{2}$的形式,其中B为最简分数$\frac{p}{q}$,要求输出$p \times inv(q) \mod 999,999,893$的值,其中$inv(q)$是q的模逆元。 输入数据格式:第一行包含一个整数t($1 \leq t \leq 10^4$),表示测试用例的数量。接下来t行,每行包含一个整数N($1 \leq N \leq 10^9$),表示对正方形纸进行的操作次数。 输出数据格式:对于每个测试用例,输出一行要求的答案。

加入题单

上一题 下一题 算法标签: