[kuangbin带你飞]专题一 简单搜索 - C - Catch That Cow
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cstring>
using namespace std;
int n, k, c, ans;
int num[];
int main()
{
// freopen("in.in","r",stdin);
while(cin>>n>>k)
{
ans = ;
queue<int>q;
q.push(n);
num[n] = ;
while(q.size())
{
c = q.front();
if(c == k)
{
ans = num[c];
break;
}
q.pop();
if(!num[c-] && c->=)
{
num[c-] = num[c] + ;
q.push(c-);
}
if(c+<= && !num[c+])
{
num[c+] = num[c] + ;
q.push(c+);
}
if(c*<= && !num[*c])
{
num[*c] = num[c] + ;
q.push(*c);
}
}
cout<<ans-<<endl;
}
return ;
}
[kuangbin带你飞]专题一 简单搜索 - C - Catch That Cow的更多相关文章
- [kuangbin带你飞]专题一 简单搜索(回顾)
A - 棋盘问题 POJ - 1321 注意条件:不能每放一个棋子,就标记一行和一列,我们直接枚举每一行就可以了. AC代码: #include<iostream> #include< ...
- [kuangbin带你飞]专题一 简单搜索 题解报告
又重头开始刷kuangbin,有些题用了和以前不一样的思路解决.全部题解如下 点击每道题的标题即可跳转至VJ题目页面. A-棋盘问题 棋子不能摆在相同行和相同列,所以我们可以依此枚举每一行,然后标记每 ...
- [kuangbin带你飞]专题一 简单搜索 - E - Find The Multiple
//Memory Time //2236K 32MS #include<iostream> using namespace std; ]; //保存每次mod n的余数 //由于198的余 ...
- [kuangbin带你飞]专题一 简单搜索 棋盘问题
题来:链接https://vjudge.net/problem/OpenJ_Bailian-132 J - 棋盘问题 1.题目: 在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别. ...
- [kuangbin带你飞]专题一 简单搜索
ID Origin Title 454 / 1008 Problem A POJ 1321 棋盘问题 328 / 854 Problem B POJ 2251 Dungeon Ma ...
- [kuangbin带你飞]专题一 简单搜索 回顾总结
第二题:bfs,忘了将queue清空. 第三题:bfs,记得使用vis数组,防止重复入队
- 迷宫问题 POJ - 3984 [kuangbin带你飞]专题一 简单搜索
定义一个二维数组: int maze[5][5] = { 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, ...
- [kuangbin带你飞]专题一 简单搜索 Find a way HDU - 2612
Pass a year learning in Hangzhou, yifenfei arrival hometown Ningbo at finally. Leave Ningbo one year ...
- Catch That Cow POJ - 3278 [kuangbin带你飞]专题一 简单搜索
Farmer John has been informed of the location of a fugitive cow and wants to catch her immediately. ...
随机推荐
- nodejs 模板引擎ejs的简单使用(2)
test.ejs <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- 转载-------- JSON 与 对象 、集合 之间的转换 JSON字符串和java对象的互转【json-lib】
转载--*--*---- 在开发过程中,经常需要和别的系统交换数据,数据交换的格式有XML.JSON等,JSON作为一个轻量级的数据格式比xml效率要高,XML需要很多的标签,这无疑占据了网络流量,J ...
- mysql服务命令行操作
启动 net start mysql 关闭 net stop mysql 登陆 mysql -hlocalhost -uusername -ppassword 退出 exit 显示数据库 show d ...
- 利用reduce方法,对数组中的json对象去重
数组中的json对象去重 var arr = [{ "name": "ZYTX", "age": "Y13xG_4wQnOWK1Q ...
- 线性筛积性函数+反演T套路——bzoj4407
#include<bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #defi ...
- BZOJ 1697: [Usaco2007 Feb]Cow Sorting牛排序(置换+贪心)
题面 Description 农夫JOHN准备把他的 N(1 <= N <= 10,000)头牛排队以便于行动.因为脾气大的牛有可能会捣乱,JOHN想把牛按脾气的大小排序.每一头牛的脾气都 ...
- NX二次开发-UFUN获取圆锥参数UF_MODL_ask_cone_parms
NX11+VS2013 #include <uf.h> #include <uf_modl.h> #include <uf_ui.h> UF_initialize( ...
- [JZOJ 5600] Arg
题意:求最少LIS覆盖... 思路: 计算\(LIS\)时我们一般用\(dp\)表示到当先位置时以当前位置结尾的\(LIS\)最长长度. 那么这个数组保证单调不降,我们考虑二进制表示. 然后就是转移了 ...
- Java-Class-C:java.util.ArrayList
ylbtech-Java-Class-C:java.util.ArrayList 1.返回顶部 1.1. import java.util.ArrayList;import java.util.Lis ...
- Centos 6 & Centos 7安装rabbitmq3.6.15(单节点)
系统准备 安装 erlang 语言环境 安装rabbitmq 配置网页插件 配置访问账号密码和权限 系统准备 centos6.5 与 centos7 都可以 ###安装依赖文件 yum -y inst ...