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

建议使用的浏览器:

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

2682:Tree

题目描述
There are N (2<=N<=600) cities,each has a value of happiness,we consider two cities A and B whose value of happiness are VA and VB,if VA is a prime number,or VB is a prime number or (VA+VB) is a prime number,then they can be connected.What's more,the cost to connecte two cities is Min(Min(VA , VB),|VA-VB|).
Now we want to connecte all the cities together,and make the cost minimal.
输入解释
The first will contain a integer t,followed by t cases.
Each case begin with a integer N,then N integer Vi(0<=Vi<=1000000).
输出解释
If the all cities can be connected together,output the minimal cost,otherwise output "-1";
输入样例
2
5
1
2
3
4
5

4
4
4
4
4
输出样例
4
-1
来自杭电HDUOJ的附加信息
Author Teddy
Recommend lcy

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

源链接: HDU-2682

最后修改于 2020-10-25T22:55:53+00:00 由爬虫自动更新

共提交 1

通过率 0.0%
时间上限 内存上限
6000/2000MS(Java/Others) 32768/32768K(Java/Others)