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

建议使用的浏览器:

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

6237:A Simple Stone Game

题目描述
After he has learned how to play Nim game, Bob begins to try another stone game which seems much easier.

The game goes like this: one player starts the game with $N$ piles of stones. There is $a_i$ stones on the $i$th pile. On one turn, the player can move exactly one stone from one pile to another pile. After one turn, if there exits a number $x(x > 1)$ such that for each pile $b_i$ is the multiple of $x$ where $b_i$ is the number of stone of the this pile now), the game will stop. Now you need to help Bob to calculate the minimum turns he need to stop this boring game. You can regard that $0$ is the multiple of any positive number.
输入解释
The first line is the number of test cases. For each test case, the first line contains one positive number $N(1 \leq N \leq 100000)$, indicating the number of piles of stones.

The second line contains $N$ positive number, the $i$th number $a_i (1 \leq a_i \leq 100000)$ indicating the number of stones of the $i$th pile.


The sum of $N$ of all test cases is not exceed $5 * 10^5$.
输出解释
For each test case, output a integer donating the answer as described above. If there exist a satisfied number $x$ initially, you just need to output $0$. It's guaranteed that there exists at least one solution.
输入样例
2
5
1 2 3 4 5
2
5 7
输出样例
2
1
来自杭电HDUOJ的附加信息
Recommend jiangzijing2015

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

源链接: HDU-6237

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

共提交 0

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