HDU_2717_Catch That Cow
很短的 BFS 队列
HDU_2717_Catch That Cow
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<queue>
using namespace std; int book[<<]={};
int que[<<];
int n,k;
int main()
{
cin>>n>>k;
queue<int>q;
que[n]=;
book[n]=;
q.push(n);
while(!q.empty())
{
int a=q.front();
q.pop();
if(a->= && !book[a-])
{
book[a-]=;
que[a-]=que[a]+;
q.push(a-);
}
if(a+<=*k && !book[a+])
{
book[a+]=;
que[a+]=que[a]+;
q.push(a+);
}
if(a*<=*k && !book[a*])
{
book[a*]=;
que[a*]=que[a]+;
q.push(a*);
}
}
cout<<que[k]<<endl;
}
HDU_2717_Catch That Cow的更多相关文章
- POJ 3278 Catch That Cow(bfs)
传送门 Catch That Cow Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 80273 Accepted: 25 ...
- 【BZOJ1623】 [Usaco2008 Open]Cow Cars 奶牛飞车 贪心
SB贪心,一开始还想着用二分,看了眼黄学长的blog,发现自己SB了... 最小道路=已选取的奶牛/道路总数. #include <iostream> #include <cstdi ...
- HDU Cow Sorting (树状数组)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2838 Cow Sorting Problem Description Sherlock's N (1 ...
- [BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居
[BZOJ1604][Usaco2008 Open]Cow Neighborhoods 奶牛的邻居 试题描述 了解奶牛们的人都知道,奶牛喜欢成群结队.观察约翰的N(1≤N≤100000)只奶牛,你会发 ...
- 细读cow.osg
细读cow.osg 转自:http://www.cnblogs.com/mumuliang/archive/2010/06/03/1873543.html 对,就是那只著名的奶牛. //Group节点 ...
- POJ 3176 Cow Bowling
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 13016 Accepted: 8598 Desc ...
- raw,cow,qcow,qcow2镜像的比较
在linux下,虚拟机的选择方式有很多,比如vmware for linux,virtual box,还有qemu,在以前,使用qemu的人不多,主要是使用起来有些麻烦,但现在随着Openstack的 ...
- poj1985 Cow Marathon (求树的直径)
Cow Marathon Time Limit: 2000MS Memory Limit: 30000K Total Submissions: 3195 Accepted: 1596 Case ...
- (01背包变形) Cow Exhibition (poj 2184)
http://poj.org/problem?id=2184 Description "Fat and docile, big and dumb, they look so stupid ...
随机推荐
- colaboratory安装指定版本的tensorflow
查看当前安装的tensorflow版本 !pip show tensorflow 安装指定版本 !pip install tensorflow==2.0 这速度,香不香.
- js判断json对象是否为空
if("{}" == JSON.stringify(json对象)) { // 满足条件就是空 }
- 【作业】Mental Rotation (模拟)
题目链接:https://vjudge.net/contest/345791#problem/L [问题描述] Mental rotation is a difficult thing to mast ...
- php 文字转换成拼音
<?php //中文字转拼音 $d=array( array("a",-20319), array("ai",-20317), array("a ...
- Hystrix【入门】
公共依赖配置: <parent> <groupId>org.springframework.boot</groupId> <artifactId>spr ...
- Linux shell 中 & && [] [[]] () [] 含义
| 语法:command 1 | command 2 功能:把第一个命令 command 1 执行的结果作为 command 2 的输入传给 command 2 & & 放在启动参数后 ...
- C语言处理字符串
1. strtok 函数原型: char * strtok(char *str, const char * delim); 注意点: 两个入参必须为字符串数组: 第一次调用要传str, delim,后 ...
- littleFS在RT1052移植笔记
环境:rt1052单片机+16G tf卡 为什么使用littleFS? NXP官方SDK支持! 先进的损耗平衡功能(wear leveling)可提供最长的快闪及内存寿命及最大的使用量.因为FALSH ...
- wc 指令
统计文件的行数, 字符数, 字节数. wc 命令的功能相对简单,参数也较少,但是是统计文本行数,字符数的利器.具体的参数和用法如下 语法 wc [OPTION]... [FILE]... wc [OP ...
- iTunes向ipad传影片
iTunes向ipad传影片(方法一) 在电脑上用itunes传视频到ipad-百度经验 iTunes向ipad传影片(方法二)