码迷,mamicode.com
首页 >  
搜索关键字:算法竞赛入门经典    ( 256个结果
(DS 《算法竞赛入门经典》)LA 3027 Corporative Network(查询某一个节点到根节点之间的距离)
题目大意:             查询某一个节点到根节点之间的距离解题思路:            加权并查集问题。之前做的题目是“查看两个或多个节点是否在同一个集合下”,现在的题目是“查询某个节点到根节点之间的距离”。之前只需要使用到father[x]这个数组,用来表示x的父亲节点是谁。现在引入dist[x]数组,用来记录x节点到根节点的距离            1)在并查集中,根节点不懂,...
分类:编程语言   时间:2015-01-03 10:39:53    阅读次数:133
(DS 《算法竞赛入门经典》)LA 3644 X-Plosives(并查集)
解题思路:      并查集A secret service developed a new kind of explosive that attain its volatile property only when a specificassociation of products occurs. Each product is a mix of two different simple com...
分类:编程语言   时间:2014-12-30 22:12:38    阅读次数:419
(DS 《算法竞赛入门经典》)UVA 11997 K Smallest Sums
题目大意:有k个数组,每个数组选取一个数,组成k^k个数。在这k^k个数中选择最小的前k个数解题思路:1、如果只有k个数组,那么最后得到的最小的前k个数应该可以由前两个数组得到的最小k个数与第三个数组按规则运算后得到。2、如果每个数组只有3个数.那么前两个数组(a:(a0,a1,a2)    b:(b0,b1,b2,a与b数组都已经有序)运算后有的结果矩阵如下:a0+b0,a0+b1,a0+b2a...
分类:编程语言   时间:2014-12-30 20:44:38    阅读次数:250
《算法竞赛入门经典》第三章 3.1
程序 3-1#include#define MAXN 100 + 10int a[MAXN];int main(){ int i, x, n = 0; while(scanf("%d, &x") == 1) a[n++] = x; for(i = n-1; i>=1;...
分类:编程语言   时间:2014-12-29 15:01:40    阅读次数:120
《算法竞赛入门经典》第二章 2.3
程序2-7 略去程序2-8 1 #define LOCAL 2 #include 3 #define INF 100000000 4 int main() 5 { 6 #ifdef LOCAL 7 freopen("data.in","r",stdin); 8 freope...
分类:编程语言   时间:2014-12-28 14:05:16    阅读次数:184
《算法竞赛入门经典》第二章 2.2
程序2-4 1 #include 2 #include 3 int main() 4 { 5 int n, count = 0; 6 scanf("%d",&n); 7 while(n>1) 8 { 9 if(n % 2 ==1) n = 3*n +1...
分类:编程语言   时间:2014-12-28 01:41:56    阅读次数:152
《算法竞赛入门经典》第二章 2.1
程序2-1 1 #include 2 #include 3 int main() 4 { 5 int n; 6 scanf("%d",&n); 7 for(int i=1;i 2 #include 3 int main() 4 { 5 int a, b, n; 6 ...
分类:编程语言   时间:2014-12-28 00:19:37    阅读次数:167
《算法竞赛入门经典》1.5.6上机练习
习题1-1 平均数(average)1 #include2 int main()3 {4 int a,b,c;5 scanf("%d%d%d",&a,&b,&c);6 printf("%0.3lf",(a+b+c)/3.0);7 return 0;8 }本题重点在于格...
分类:编程语言   时间:2014-12-27 01:26:43    阅读次数:211
《算法竞赛入门经典》第一章1.4
代码1-11 1 #include 2 int main() 3 { 4 int a,b,n,m; 5 scanf("%d%d",&n,&m); 6 a=(4*n-m)/2; 7 b=n-a; 8 if(n%2==1||a 2 int main() 3 { 4...
分类:编程语言   时间:2014-12-25 23:32:08    阅读次数:299
《算法竞赛入门经典》第一章1.3
例题1-2程序1-61 #include2 #include3 int main()4 {5 int n;6 scanf("%d",&n);7 printf("%d%d%d",n%10,n/10%10,n/100);8 return 0;9 }程序1-71 #incl...
分类:编程语言   时间:2014-12-25 23:21:06    阅读次数:249
256条   上一页 1 ... 19 20 21 22 23 ... 26 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!