nflsoj 1351 抓住奶牛】的更多相关文章

题意:给定农夫和奶牛的初始位置,农夫可以当前位置+1.-1.*2三种移动方式,问最少需要多少分钟抓住奶牛 AC代码: #include<cstdio> #include<cstring> #include<queue> using namespace std; const int maxn=100000+5; const int dx[]={-1,1,2}; int d[maxn]; int n,k; int bfs(){ queue<int>q; mems…
题目链接:http://i.cnblogs.com/EditPosts.aspx?opt=1 Catch That Cow Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 7909    Accepted Submission(s): 2498 Problem Description Farmer John has been inform…
codevs 3060 抓住那头奶牛 USACO  时间限制: 1 s  空间限制: 16000 KB  题目等级 : 黄金 Gold   题目描述 Description 农夫约翰被告知一头逃跑奶牛的位置,想要立即抓住它,他开始在数轴的N 点(0≤N≤100000),奶牛在同一个数轴的K 点(0≤K≤100000).约翰有两种移动方式:1 分钟内从x 点移动到x+1 或x-1:1 分钟内从x 点移动到2x.假设奶牛不会移动,约翰抓住它需要多少时间? 输入描述 Input Description…
3060 抓住那头奶牛 USACO 时间限制: 1 s 空间限制: 16000 KB 题目等级 : 黄金 Gold 题目描述 Description 农夫约翰被告知一头逃跑奶牛的位置,想要立即抓住它,他开始在数轴的N 点(0≤N≤100000),奶牛在同一个数轴的K 点(0≤K≤100000).约翰有两种移动方式:1 分钟内从x 点移动到x+1 或x-1:1 分钟内从x 点移动到2x.假设奶牛不会移动,约翰抓住它需要多少时间? 输入描述 Input Description 一行两个整数N 和K,…
3060 抓住那头奶牛 USACO  时间限制: 1 s  空间限制: 16000 KB  题目等级 : 黄金 Gold   题目描述 Description 农夫约翰被告知一头逃跑奶牛的位置,想要立即抓住它,他开始在数轴的N 点(0≤N≤100000),奶牛在同一个数轴的K 点(0≤K≤100000). 约翰有两种移动方式:1 分钟内从x 点移动到x+1 或x-1:1 分钟内从x 点移动到2x.假设奶牛不会移动,约翰抓住它需要多少时间? 输入描述 Input Description 一行两个整…
1646: [Usaco2007 Open]Catch That Cow 抓住那只牛 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 634  Solved: 310[Submit][Status] Description Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. He starts at a p…
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…
BFS... -------------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<queue>   #define rep( i , n ) for( int i =…
http://www.lydsy.com/JudgeOnline/problem.php?id=1646 这一题开始想到的是dfs啊,,但是本机测样例都已经re了... 那么考虑bfs...很巧妙? 首先我们得确定一个上下界. 当到达距离<0时显然不可能再走了(准确来说绝对不会比当前优),所以这里可以剪枝. 当到达距离>max(n, k)+1时也不能再走了(准确说不会比之前的优,比如说,你走到了k+2,但是之前就可在某个小于k的地方走×2的就走到了,那么就比这个少了1步)所以这里可以剪枝 然后…
题目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 lin…