Catch That Cow
Time Limit: 2000MS
Memory Limit: 65536K
Total Submissions: 43851
Accepted: 13674
Description
Farmer John has been informed of the location of a fugitiv...
分类:
其他好文 时间:
2014-06-05 07:45:38
阅读次数:
220
裸dijkstra
思路:以x为源点,求到其他点的最短路,之后把邻接矩阵转置,再求一次x源
点的最短路,这样就一次是来的,一次是走的,相加迭代最大值即可
代码:
/*
poj 3268
8108K 47MS
*/
#include
#include
#define MAXN 1005
#define MAX_INT 2147483647
using namespace s...
分类:
其他好文 时间:
2014-06-04 23:32:57
阅读次数:
303
http://poj.org/problem?id=3270这道题就是给你一个无序序列转换成有序序列需要花费的代价最小,交换a和b代价为a+b; 1
#include 2 #include 3 #include 4 #define maxn 20000 5 using namespace st...
分类:
其他好文 时间:
2014-06-03 13:14:32
阅读次数:
272
Farmer 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,0...
分类:
其他好文 时间:
2014-06-03 05:30:23
阅读次数:
394
题目大意:
一个农主寻找牛。给出农主的位置n和牛的位置k。农主可以通过n-1或者n+1或者n*2的步伐找牛,问至少多少步才能找到自己的牛。解题思路:
简单的BFS。把农主的每一种可能的步伐通过BFS存到栈中,然后看最少多少步到达K坐标。代码: 1 #include 2 #include 3 ...
分类:
其他好文 时间:
2014-05-31 15:27:27
阅读次数:
252
题目链接:http://poj.org/problem?id=3617题意:
已知一段长度为N的字符串,让你构造一个字典序最小的字符串.构造的规则如下:如果原始字符串的头部 尾部则删除尾部的字符添加到新字符串中.解题思路:
首先用两个索引记录首尾的位置,然后依次比较两者的值,若头部的值小则头部索引....
分类:
其他好文 时间:
2014-05-21 19:05:31
阅读次数:
245
POJ 3278 Catch That Cow
题目大意:
告诉你起点位置和终点位置,你可以有三种操作,从某个位置x,可以到达x-1,x+1,2*x,问你从起点到终点最短时间?
解题思路:
利用bfs枚举位置即可
但是刨除以下情况,也就是剪枝一下
1、当x终点位置时,x+1和2*x均不能到达
解题代码:见本文详细...
分类:
其他好文 时间:
2014-05-21 14:33:08
阅读次数:
241
Catch That Cow
Problem Description
Farmer 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 li...
分类:
其他好文 时间:
2014-05-21 07:02:40
阅读次数:
312
POJ 3278 Catch That Cow...
分类:
其他好文 时间:
2014-05-13 08:23:36
阅读次数:
328
Problem Description
Many years ago , in Teddy’s hometown there was a man who was called “Bone Collector”. This man like to collect varies of bones , such as dog’s , cow’s , also he went to the grav...
分类:
其他好文 时间:
2014-05-13 06:58:19
阅读次数:
523