随笔分类 -  POJ

摘要:为什么写这个呢?因为那天听到了这个词,属于MST的扩展……最小K度树有空研究。 一.理论准备 需要读者事先懂得prime算法,不太了解的请看博主这一篇http://www.cnblogs.com/hxsyl/p/3286956.html,也需要读者对DP了解一些。 先看一个结论:次小生成树可由最小生成树换一条边得到,笔者认为很... 阅读全文
posted @ 2013-08-30 10:02 加拿大小哥哥 编辑
摘要:一.理论准备 从图上看出:C[1] = A[1],C[2] = A[1] + A[2],C[3] = A[3],C[4] = A[1] + A[2] + A[3] + A[4],C[5] = A[5],C[6] = A[5] + A[6],C[7] = A[7],C[8] = A[1] + A[2] + A[3] + A[4] + A[5] +... 阅读全文
posted @ 2013-08-17 15:58 加拿大小哥哥 编辑
摘要:一.理论准备 这两天看到了图论的二部图,闲着没事就水了一道。 先看增广路的定义:增广路,也称增广轨或交错轨: 若P是图G中一条连通两个未匹配顶点的路径,并且属于M的边和不属于M的边(即已匹配和待匹配的边)在P上交替出现,则称P为相对于M的一条增广路径。 由增广路的定义可以推出下述三个结论:P的路径长... 阅读全文
posted @ 2013-08-15 14:13 加拿大小哥哥 编辑
摘要:一.概念引入 AC过后,突然想起费马点和最小覆盖圆的圆心有关系吗?答案是没关系,如下图:费马点肯定在等腰梯形内,不是在圆心。 模拟退火算法与初始值无关,算法求得的解与初始解状态S(是算法迭代的起点)无关;模拟退火算法具有渐近收敛性,已在理论上被证明是一种以概率收敛于全局最优解的全局优化算法;模拟退火算法具有并行性。 三... 阅读全文
posted @ 2013-08-12 13:42 加拿大小哥哥 编辑
摘要:http://www.cnblogs.com/zhourongqing/archive/2011/11/27/2265384.htmlhttp://www.cnblogs.com/pushing-my-way/archive/2012/08/23/2652033.html 阅读全文
posted @ 2013-04-21 22:24 加拿大小哥哥 编辑
摘要:http://www.cnblogs.com/linpeidong2009/archive/2012/04/23/2467048.htmlhttp://blog.163.com/xdu_cfcry/blog/static/1694623032010718274132/ 阅读全文
posted @ 2013-04-20 22:07 加拿大小哥哥 编辑
摘要:1132: 最少硬币问题Time Limit: 1500 ms Memory Limit: 10000 kB Total Submit : 909(187 users)Accepted Submit : 241(132 users)Page View : 9030Font Style: Aa Aa Aa 设有n 种不同面值的硬币,各硬币的面值存于数组T[1:n]中。现要用这些面值的硬币来找钱。可以使用的各种面值的硬币个数存于数组Coins[1:n]中。对任意钱数0≤m≤20001,设计一个用最少硬币找钱m的方法。编程任务:对于给定的1≤n≤10,硬币面值数组T和可以使用的各种面值的硬币个数数. 阅读全文
posted @ 2013-04-20 22:05 加拿大小哥哥 编辑
摘要:Google BookTime Limit:1 Second Memory Limit:32768 KBYou, the best hacker in the world, want to download the books published on Google Book. After some investigation, you found that the address of each page consists of two parts. The first part is the page number, the second part is the signature whi 阅读全文
posted @ 2013-04-17 11:54 加拿大小哥哥 编辑
摘要:1 2 //坐标精度是int 3 /* 4 圆心位于 5 */ 6 #include <iostream> 7 #include <cstdlib> 8 #include <cstring> 9 #include <cmath>10 using namespace std; 11 12 const int N = 1005;13 typedef struct Part 14 {15 int a, b;16 };17 Part q[N];18 19 typedef struct Node 20 {21 int left, right;22 };23 阅读全文
posted @ 2013-04-13 23:22 加拿大小哥哥 编辑
摘要:题目大意:本题就是给出一个循环队列,队列中的元素只能是1和0,现在我们有两种旋转方法,就是连选三个我可以选择顺时针旋转或者是逆时针旋转,当然,旋转之后的结果我们很容易就知道了就是把一个元素移动两格,中间的元素位置不变。最后要求最后我是否有办法使所有的1在一起,所有的0在一起. 1 #include<cmath> 2 #include<cstdio> 3 int main() 4 { 5 int i,k,t,r,res,cnt,ans; 6 scanf("%d",&t); 7 while(t--) 8 { 9 scanf("%d&qu 阅读全文
posted @ 2013-01-06 22:35 加拿大小哥哥 编辑
摘要:Function Run FunTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 13491Accepted: 7023DescriptionWe all love recursion! Don't we? Consider a three-parameter recursive function w(a, b, c): if a <= 0 or b <= 0 or c <= 0, then w(a, b, c) returns: 1 if a > 20 or b > 20 or c > 阅读全文
posted @ 2012-11-17 20:34 加拿大小哥哥 编辑
摘要:将字母A-Z编码,A为1,B为2,……依此类推,Z为26;则ABC编码为123。但是反向解码时,解码结果不唯一,比如123可以解码为 1-2-3:ABC,解码为12-3:LC,解码为1-23:AW(注意,127不能解码为1-27,因为范围只能为1-26)。现给出一组编码后的数字串,让你求该数字串可以有几种解码方式(上例中,123对应着3种解码方式)。问题输入将保证其为一个合法的数字串。比如100是 一个不合法的数字串,因为0或者00不代表一个字母;此外01不能视为1。 Sample Input25114 1111111111 3333333333 Sample Output6 89 1 1 / 阅读全文
posted @ 2012-09-15 13:37 加拿大小哥哥 编辑
摘要:View Code 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 using namespace std; 5 6 int hash[30]; 7 bool loc[20000000]; 8 char str[1000000]; 9 10 int main()11 {12 int n,m,cnt,sum,len,ans,i,j;13 while(scanf("%d%d",&n,&m)!=EOF)14 {15 memset(loc,0,sizeof 阅读全文
posted @ 2012-09-11 20:03 加拿大小哥哥 编辑
摘要:1 //共T条路,求从S到E经过N条路径的最短路径 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 #define CIR(n, m) for (int i=0; i>= 1;48 }... 阅读全文
posted @ 2012-08-30 14:16 加拿大小哥哥 编辑
摘要:2787:算24查看提交统计提问时间限制:3000ms内存限制:65536kB描述给出4个小于10个正整数,你可以使用加减乘除4种运算以及括号把这4个数连接起来得到一个表达式。现在的问题是,是否存在一种方式使得得到的表达式的结果等于24。这里加减乘除以及括号的运算结果和运算的优先级跟我们平常的定义一致(这里的除法定义是实数除法)。比如,对于5,5,5,1,我们知道5 * (5 – 1 / 5) = 24,因此可以得到24。又比如,对于1,1,4,2,我们怎么都不能得到24。输入输入数据包括多行,每行给出一组测试数据,包括4个小于10个正整数。最后一组测试数据中包括4个0,表示输入的结束,这组数 阅读全文
posted @ 2012-08-23 20:18 加拿大小哥哥 编辑
摘要:Minimum Transport CostTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4487Accepted Submission(s): ... 阅读全文
posted @ 2012-08-21 20:22 加拿大小哥哥 编辑
摘要:I Wanna Go HomeTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 2488Accepted: 1041DescriptionThe country is facing a terrible civil war----cit... 阅读全文
posted @ 2012-08-21 18:16 加拿大小哥哥 编辑
摘要:1437: 校长杯Time Limit: 1500 ms Memory Limit: 32000 kB Judge type: Multi-cases Special JudgeTotal Submit : 110(53 users)Accepted Submit : 67(47 users)Pa... 阅读全文
posted @ 2012-08-21 08:30 加拿大小哥哥 编辑
摘要:Catch That CowTime Limit: 2000MSMemory Limit: 65536KTotal Submissions: 31637Accepted: 9740DescriptionFarmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a point N (0 ≤ N ≤ 100,000) on a number line and the cow is at a point K (0 ≤ K ≤ 100, 阅读全文
posted @ 2012-08-20 17:47 加拿大小哥哥 编辑
摘要:The CastleTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 5557Accepted: 3129Description 1 2 3 4 5 6 7 ############################# 1 # | # | # | | # #####---#####---#---#####---# 2 # # | # # # # # #---#####---#####---#####---# 3 # | |... 阅读全文
posted @ 2012-08-17 15:15 加拿大小哥哥 编辑