A10548 | PLEASE
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
As we all know Barney's job is "PLEASE" and he has not much to do at work. That's why he started playing "cups and key". In this game there are three identical cups arranged in a line from left to right. Initially key to Barney's heart is under the middle cup.
Then at one turn Barney swaps the cup in the middle with any of other two cups randomly (he choses each with equal probability), so the chosen cup becomes the middle one. Game lasts $n$ turns and Barney independently choses a cup to swap with the middle one within each turn, and the key always remains in the cup it was at the start.
After $n$ -th turn Barney asks a girl to guess which cup contains the key. The girl points to the middle one but Barney was distracted while making turns and doesn't know if the key is under the middle cup. That's why he asked you to tell him the probability that girl guessed right.
Number $n$ of game turns can be extremely large, that's why Barney did not give it to you. Instead he gave you an array $a_{1},a_{2},...,a_{k}$ such that
in other words, $n$ is multiplication of all elements of the given array.
Because of precision difficulties, Barney asked you to tell him the answer as an irreducible fraction. In other words you need to find it as a fraction $p/q$ such that , where  is the greatest common divisor. Since $p$ and $q$ can be extremely large, you only need to find the remainders of dividing each of them by $10^{9}+7$ .
Please note that we want  of $p$ and $q$ to be $1$ , not  of their remainders after dividing by $10^{9}+7$ .
Then at one turn Barney swaps the cup in the middle with any of other two cups randomly (he choses each with equal probability), so the chosen cup becomes the middle one. Game lasts $n$ turns and Barney independently choses a cup to swap with the middle one within each turn, and the key always remains in the cup it was at the start.
After $n$ -th turn Barney asks a girl to guess which cup contains the key. The girl points to the middle one but Barney was distracted while making turns and doesn't know if the key is under the middle cup. That's why he asked you to tell him the probability that girl guessed right.
Number $n$ of game turns can be extremely large, that's why Barney did not give it to you. Instead he gave you an array $a_{1},a_{2},...,a_{k}$ such that
in other words, $n$ is multiplication of all elements of the given array.
Because of precision difficulties, Barney asked you to tell him the answer as an irreducible fraction. In other words you need to find it as a fraction $p/q$ such that , where  is the greatest common divisor. Since $p$ and $q$ can be extremely large, you only need to find the remainders of dividing each of them by $10^{9}+7$ .
Please note that we want  of $p$ and $q$ to be $1$ , not  of their remainders after dividing by $10^{9}+7$ .
输入格式
The first line of input contains a single integer $k$ ( $1<=k<=10^{5}$ ) — the number of elements in array Barney gave you.
The second line contains $k$ integers $a_{1},a_{2},...,a_{k}$ ( $1<=a_{i}<=10^{18}$ ) — the elements of the array.
The second line contains $k$ integers $a_{1},a_{2},...,a_{k}$ ( $1<=a_{i}<=10^{18}$ ) — the elements of the array.
输出格式
In the only line of output print a single string $x/y$ where $x$ is the remainder of dividing $p$ by $10^{9}+7$ and $y$ is the remainder of dividing $q$ by $10^{9}+7$ .
输入输出样例
输入 #1
1 2
输出 #1
1/2
输入 #2
3 1 1 1
输出 #2
0/1
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted