poj3278】的更多相关文章

Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 73973   Accepted: 23308 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,00…
这一题是练习广度优先搜索很好的例题,在很多广搜教学中经常用到,放在这里供学习搜索算法的孩纸们看看= = 题目大意:一维数轴上,农夫在N点,牛在K点,假定牛不会移动,农夫要找到这头牛只能够进行以下三种移动方法 2*N-跳跃到两倍于自己所在的位置 N+1 -右移一位 N -1 -左移一位 BFS解法解析:按照移动步数依次遍历队首,pop掉,并拓展出下一步所有可走位置并依次压入队列(不懂的孩纸们找度娘,很基础的数据结构)中,在这里为Code方便,我使用STL中的queue. Code如下: //从N到…
Catch That Cow DescriptionFarmer 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,000) on the same number l…
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 line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer Jo…
题目:                                                                                                                                                          Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K       Description Farmer John has be…
M - 搜索 Crawling in process... Crawling failed Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3278 Description Farmer John has been informed of the location of a fugitive cow and wants to catch…
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 line and the cow is at a point K (0 ≤ K ≤ 100,000) on the same number line. Farmer Jo…
题目链接:http://poj.org/problem?id=3278 分析:广搜,每次三种情况枚举一下,太水不多说了. #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #include <queue> #include <cstdlib> #include <vector&g…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 89836   Accepted: 28175 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,00…
#include<iostream> #define MAX 100001 int john,cow; int queue[MAX]; int vis[MAX]; int ans; void bfs() { int tail,head; tail=head=; int start=john; queue[tail++]=start; vis[start]=; while(head!=tail) { int cur,next; cur=queue[head++]; if(cur==cow) {…