当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6359:Just So You Know

题目描述
Matthew is a wise man and Jesse is his best friend. One day, Jesse gave Mattew an integer sequence $A$ of length $n$ and marked one continuous subsequence $B$ of $A$ privately. Mattew didn't know the sequence $B$ at first, but he can guess out the sequence by conjectures. That is, once he claims some conjecture, Jesse will immediately tell him whether the conjecture is true or not.

Matthew has known the sequence $B$ is an interval selected from the sequence $A$ with equal probability. A wise man is never confused, so Matthew will minimize the expected number of conjectures he needs to figure out the sequence $B$. Could you please determine that expected value? Your answer should be an irreducible fraction $p / q$, which means $p$ and $q$ are coprime.
输入解释
The first line contains one integer $T$, indicating the number of test cases.
The following lines describe all the test cases. For each test case:
The first line contains one integer $n$.
The second line contains $n$ space-separated integers $A_1, A_2, \cdots, A_n$.
$1 \leq T \leq 1000$, $1 \leq n \leq 10^6$, $0 \leq A_i < 100$ $(i = 1, 2, \cdots, n)$.
It is guaranteed that the sum of $n$ in all test cases does not exceed $10^7$ and the size of the standard input file does not exceed $24$ MiB.
输出解释
For each test case, print in one line the answer as an irreducible fraction $p / q$ if $q \neq 1$ or a simple $p$ otherwise.
输入样例
3
2
1 1
4
1 2 1 1
6
1 1 4 5 1 4
输出样例
1
29/10
85/21

提示
Here is one possible best solution for the second sample. Claim Conjecture 1 firstly and others consequently following the instructions.
Conjecture 1: The number of 1 in B is odd. If true, go to Conjecture 2, else go to Conjecture 3.
Conjecture 2: The length of B is 1. If true, B is [1], else go to Conjecture 4.
Conjecture 3: The first element of B is 1. If true, go to Conjecture 5, else go to Conjecture 6.
Conjecture 4: The length of B is 4. If true, B is [1, 2, 1, 1], else go to Conjecture 7.
Conjecture 5: The length of B is 3. If true, B is [1, 2, 1], else B is [1, 1].
Conjecture 6: The length of B is 1. If true, B is [2], else B is [2, 1, 1].
Conjecture 7: The first element of B is 1. If true, B is [1, 2], else B is [2, 1].
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6359

最后修改于 2020-10-25T23:30:37+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
7000/3500MS(Java/Others) 262144/262144K(Java/Others)