编程介的小学生
2017-11-18 15:22GSM
10Problem Description
Xiao Ming is traveling around several cities by train. And the time on the train is very boring, so Xiao Ming will use the mobile Internet. We all know that mobile phone receives the signal from base station and it will change the base station when moving on the train. Xiao Ming would like to know how many times the base station will change from city A to city B.
Now, the problem is simplified. We assume the route of train is straight, and the mobile phone will receive the signal from the nearest base station.
Input
Multiple cases. For each case, The first line: N(3<=N<=50) - the number of cities, M(2<=M<=50) - the number of base stations. Then there are N cities with coordinates of (x, y) and M base stations with coordinates of (x, y) - (0<=x<=1000, 0<=y<=1000, both x and y is integer).Then there is a number : K, the next, there are K queries, for each query, each line, there are two numbers: a, b.
Output
For each query, tell Xiao Ming how many times the base station will change from city a to city b.
Sample Input
4 4
0 2
1 3
1 0
2 0
1 2
1 1
2 2
2 1
4
1 2
1 3
1 4
3 4
Sample Output
0
1
2
1
- 点赞
- 回答
- 收藏
- 复制链接分享
1条回答
为你推荐
- Xpath查询返回部分空值(PHP)
- xpath
- xml
- soap
- php
- 1个回答
- HERE Api:使用Positioning API获得Lat和Long
- rest
- api
- php
- 1个回答
- JQuery:使用.val()函数不会更改下拉值
- javascript
- php
- jquery
- 3个回答
- 解码json响应并为每个插入使用
- json
- mysql
- php
- parsing
- 3个回答
- 求一个Java或者JS代码的算法
- java
- javascript
- 3个回答