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

建议使用的浏览器:

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

7050:Link with Limit

题目描述
Link has a function $f(x)$, where $x$ and $f(x)$ are both integers in $[1,n]$.

Let $f_n(x)=f(f_{n-1}(x))$ and $f_1(x) = f(x)$, he define the power of a number $x$ as:
$$g(x) = \lim \limits_{n \to + \infty} \frac{1}{n} \sum_{i=1}^{n} f_i(x)$$

He wants to know whether $x$ has the same power for all $x \in [1,n]$.
输入解释
The input consists of multiple test cases.

The first line contains an integer $T$ ($1 \leq T \leq 100$) -- the number of test cases.

For each test case:

In the first line, there is an integer $n$ ($1 \leq n \leq 10^5$).

In the second line, there are $n$ integers, the $i$-th integer shows the value of $f(i)$ ($1 \leq f(i) \leq n$).

It is guaranteed that the sum of $n$ over all test cases will not exceed $10^6$.
输出解释
For each test case, output 'YES' if all $x$ have the same power. Otherwise, output 'NO'.
输入样例
2
2
1 2
2
1 1
输出样例
NO
YES

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

源链接: HDU-7050

最后修改于 2021-10-23T19:11:12+00:00 由爬虫自动更新

共提交 0

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