【POJ】3278 Catch That Cow】的更多相关文章

题目链接:http://poj.org/problem?id=3278 题意:有一头奶牛跑到了K的位置,农夫在N的位置,求最短抓到奶牛的时间. 农夫有两种移动方式. 1.步行:一分钟内从x->x+1 或者 x->x-1. 2.传送:一分钟内从x->2x. 题解:一个BFS例题.基础练手用的.queue里其实有三种状态.x-1,x+1,2x.然后去试探鸭. 代码: #include<iostream> #include<queue> #include<cstr…
bfs. /* 2717 */ #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <queue> using namespace std; #define MAXN 100001 queue<int> Q; int s[MAXN]; int n, k; int ans; void bfs() { int cur, n…
#include<stdio.h> #include<string.h> struct A{ int state; int step; }queue[]; // 结构体数组用来模拟队列,数组元素包含两个数据,state代表遍历到的数值,step所经历的步数 ]; // 这个数组用来存储访问情况 int n, k; int bfs( int aim); int main(void){ scanf("%d%d", &n, &k); if( n >…
题目传送门 /* BFS简单题:考虑x-1,x+1,x*2三种情况,bfs队列练练手 */ #include <cstdio> #include <iostream> #include <algorithm> #include <map> #include <queue> #include <set> #include <cmath> #include <cstring> using namespace std…
POJ 3278 Catch That Cow(赶牛行动) Time Limit: 1000MS    Memory Limit: 65536K 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…
题目链接:http://poj.org/problem?id=3278 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 124528   Accepted: 38768 Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. H…
Description Georgia and Bob decide to play a self-invented game. They draw a row of grids on paper, number the grids from left to right by 1, 2, 3, ..., and place N chessmen on different grids, as shown in the following figure for example: Georgia an…
Description 有两堆石子,数量任意,可以不同.游戏开始由两个人轮流取石子.游戏规定,每次有两种不同的取法,一是可以在任意的一堆中取走任意多的石子:二是可以在两堆中同时取走相同数量的石子.最后把石子全部取完者为胜者.现在给出初始的两堆石子的数目,如果轮到你先取,假设双方都采取最好的策略,问最后你是胜者还是败者. Input 输入包含若干行,表示若干种石子的初始情况,其中每一行包含两个非负整数a和b,表示两堆石子的数目,a和b都不大于1,000,000,000. Output 输出对应也有…
Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 88732   Accepted: 27795 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…
传送门 Catch That Cow Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 80273   Accepted: 25290 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 ≤ 10…