求解连通性问题,最好用的当然是并查集了,可以使用深搜或者广搜。这道题目的意思是给定一些道路,如果把其中一个顶点去掉,那么需要建立多少条道路才能联通所有顶点。这道题目如果用朴素的并查集的话第四个测试用例会超时,因此想到带路径压缩的并查集。递归或者非递归方式都可以,对于这道题目来说不会差别很大,不过用递...
分类:
其他好文 时间:
2014-09-19 22:19:06
阅读次数:
229
2-06. 数列求和(20)(ZJUPAT 数学)...
分类:
其他好文 时间:
2014-09-19 21:14:26
阅读次数:
183
2-05. 求集合数据的均方差(15) (ZJUPAT 数学)...
分类:
其他好文 时间:
2014-09-19 19:23:55
阅读次数:
360
#include#include#include#includeusing namespace std;int main(){ string a,b; int tag,radix; int anum,bnum; //freopen("1010-in.txt","r",stdin); //f...
分类:
其他好文 时间:
2014-09-18 23:32:04
阅读次数:
266
1005. 继续(3n+1)猜想 (25) (ZJUPAT 数学)...
分类:
其他好文 时间:
2014-09-18 22:17:44
阅读次数:
180
#include#include#include#includeusing namespace std;int main(){ int n,d; stack s; //freopen("1015-in.txt","r",stdin); //freopen("1015-out.t...
分类:
其他好文 时间:
2014-09-18 22:13:54
阅读次数:
173
1003. 我要通过!(20) (ZJUPAT 模拟)...
分类:
其他好文 时间:
2014-09-18 20:47:24
阅读次数:
185
1004. 成绩排名 (20) (ZJUPAT 结构体)...
分类:
其他好文 时间:
2014-09-18 20:44:44
阅读次数:
160
A suffix tree (also called PAT tree or, in an earlier form, position tree) is a compressed trie containing all the suffixes of the given text as their...
分类:
其他好文 时间:
2014-09-18 18:49:24
阅读次数:
342
问题描述题目来源:PAT ds 2-08给定四个数字a, b, c, d,取值范围为[1, 13];添加合适的运算符 + , - , * , /, 和括号(, )使得表达式等于24,给出一种可能的表达式方案;如果不可能则返回-1。例如:输入2, 3, 12, 12, 输出 ((3-2)*12) + ...
分类:
其他好文 时间:
2014-09-18 12:45:53
阅读次数:
283