开汽车找房子
来源:互联网 发布:编辑地图的软件 编辑:程序博客网 时间:2024/05/02 05:47
The main street of Berland is a straight line with n houses built along it (n is an even number). The houses are located at both sides of the street. The houses with odd numbers are at one side of the street and are numbered from 1 ton - 1 in the order from the beginning of the street to the end (in the picture: from left to right). The houses with even numbers are at the other side of the street and are numbered from2 to n in the order from the end of the street to its beginning (in the picture: from right to left). The corresponding houses with even and odd numbers are strictly opposite each other, that is, house 1 is opposite house n, house 3 is opposite house n - 2, house 5 is opposite house n - 4 and so on.
Vasya needs to get to house number a as quickly as possible. He starts driving from the beginning of the street and drives his car to housea. To get from the beginning of the street to houses number1 and n, he spends exactly1 second. He also spends exactly one second to drive the distance between two neighbouring houses. Vasya can park at any side of the road, so the distance between the beginning of the street at the houses that stand opposite one another should be considered the same.
Your task is: find the minimum time Vasya needs to reach house a.
Input
The first line of the input contains two integers, n anda (1 ≤ a ≤ n ≤ 100 000) — the number of houses on the street and the number of the house that Vasya needs to reach, correspondingly. It is guaranteed that numbern is even.
Output
Print a single integer — the minimum time Vasya needs to get from the beginning of the street to housea.
Sample Input
4 2
2
8 5
3题目大意:偶数的房屋在街的另一边,编号从2到n的顺序从街上的开始(图中:从右到左)。奇数和偶数相应的房屋与严格彼此相反,也就是说,1是对面的房子n,n - 2 3对上门的房子5是对面的房子n - 4等等。Vasya需要尽快门牌号。他开始开车从一开始的街道和开车的房子。从一开始的街道房屋数量1,n,他花1秒。他还花了一个第二驱动两个邻近的房屋之间的距离。题解:#include<stdio.h>int main(){int n,m,k;while(~scanf("%d%d",&n,&m)){if(m%2==0)printf("%d\n",n/2-m/2+1);//当要到达房屋为偶数时elseprintf("%d\n",m/2+1);//当要达到房屋为奇数时}}
- 开汽车找房子
- 找房子
- 找房子
- 开公司的心得,找房子
- 找房子山西卫视
- 找房子了
- 找房子好困难
- 最近在找房子
- 又又找房子!!!
- 20090614找房子
- 找房子的两天
- CF 开车找房子
- 利用python找房子
- 又开始找房子了
- 实习第一周:找房子
- 找房子的辛酸事
- 又要找房子了
- 人通过中介找房子
- Android Service完全解析,关于服务你所需知道的一切(上)
- iOS学习资源汇总(开源项目、第三方库、技术博客等等)
- Java.简单TCP服务器
- WEB开发者应该有哪些必备的技能?
- 小方法教你让PPT的箭头跟着目标走
- 开汽车找房子
- MongoDB的学习(零)-简介与安装
- Java.UDP.DatagramSocket-DatagramPacket
- 零基础开始学 Web 前端开发,有什么建议吗?--知
- Android高效加载大图、多图解决方案,有效避免程序OOM
- 从此不求人:自主研发一套PHP前端开发框架(33)之插件化架构实现中
- android 异步回调机制
- UIView与CALayer的区别,很详细
- 初来乍到