A11357 | Fractal Origami
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of $q$ .
 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](https://en.wikipedia.org/wiki/Modular_multiplicative_inverse) of $q$ .
输入格式
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.
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.
输出格式
For each test case, print on a new line the required answer.
输入输出样例
输入 #1
3 1 2 3
输出 #1
0 1 714285638
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)$ .
Crease lines after $1$ operation $(\dfrac{M}{V} = 0)$ .Crease lines after $2$ operations $(\dfrac{M}{V} = \sqrt{2} - 1)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted