HDU_5523Game
Game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 159 Accepted Submission(s): 74
to adjacent pillar,or he can jump to boundary ( the first pillar or the N-th pillar) by using his superpower.However,he needs to follow a rule:if he left the pillar,he no can not get here anymore.In order to save his power,XY wants to use the minimum number
of superpower to pass the game.
For each case,the line contains three integers:N,S and T.(1≤N≤10000,1≤S,T≤N)
4 1 4 4 1 3
0 1 无解的情况只有起点和终点位置一样且N不为1。终点和起点都在边界上答案为0,如果起点在边界上或者起点终点相邻答案为1,其他答案为2. #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <string> #include <cmath> using namespace std; int main() { int n, s, t; while (cin >> n>>s >> t) { if (n == 1) cout << 0<< endl; else { if (s == t) cout << -1<< endl; else if ((s == 1 && t == n) || (s == n && t == 1)) cout << 0<< endl; else if ((s == 1 || s == n) || abs(s-t) == 1) cout << 1<< endl; else cout << 2<< endl; } } return 0;}
HDU_5523Game的更多相关文章
随机推荐
- 每周.NET前沿技术文章摘要(2017-05-17)
汇总国外.NET社区相关文章,覆盖.NET ,ASP.NET等内容: .NET .NET Framework 4.7正式发布 链接: http://www.infoq.com/cn/news/2017 ...
- Handler的解析和使用
1.handler为android中多线程间通信的一种机制, @1android中只允许在UI线程(主线程)操作或改变UI,其他线程不能操作UI. @2其他线程有刷新UI的需要,所以得告诉UI线程,这 ...
- bzoj 4539: [Hnoi2016]树
Description 小A想做一棵很大的树,但是他手上的材料有限,只好用点小技巧了.开始,小A只有一棵结点数为N的树,结 点的编号为1,2,-,N,其中结点1为根:我们称这颗树为模板树.小A决定通过 ...
- HTML5 给图形绘制阴影(绘制五角星示例)
几个属性 shadowOffsetX:阴影的横向位移量. shadowOffsetY:阴影的纵向位移量. shadowColor:阴影的颜色. shadowBlur:阴影的模糊范围. 属性说明 sha ...
- Oracle ADG搭建
Oracle Active Data Guard搭建 一:安装 1.基础环境配置 1.1.开启强制日志记录 DG日志发送方式中ARCH进程和LGWR进程的ASYNC模式都是基于日志同步的,所以我们必须 ...
- bat检测文件大小并邮件报警
rem 获取当前日期 set TimeName=%date:~0,4%%date:~5,2%%date:~8,2% rem 获取文件名 set file=%TimeName% rem 获取文件大小 ...
- jquery 怎么判断当前按钮是否是disabled 属性
https://zhidao.baidu.com/question/1733097469792964827.html 应该用 prop("disabled") 有则返回true吧? ...
- Spring Boot实战:Restful API的构建
上一篇文章讲解了通过Spring boot与JdbcTemplate.JPA和MyBatis的集成,实现对数据库的访问.今天主要给大家分享一下如何通过Spring boot向前端返回数据. 在现在的开 ...
- 《深入理解Java虚拟机:JVM高级属性与最佳实践》读书笔记(更新中)
第一章:走进Java 概述 Java技术体系 Java发展史 Java虚拟机发展史 1996年 JDK1.0,出现Sun Classic VM HotSpot VM, 它是 Sun JDK 和 Ope ...
- css实现椭圆、半椭圆
一.自适应的椭圆 1. 椭圆 css .ellipse{ width: 250px; height: 150px; margin: 50px; background: #FFD900; border- ...