编程介的小学生 2019-10-03 20:10 采纳率: 20.5%
浏览 59

Countryside Highway 的算法问题

Description

Regional government wishes to build a new highway across the region, and it seems that the best route for the highway goes across the Kvadratnaya village. The village consists of the N x N square estates. All estates have a size of 100 by 100 meters. Therefore, in the coordinate system tied to the village, the southwestern corner of the village has coordinates (0, 0), and northeastern corner - coordinates (N*100, N*100). The highway will cross the village form the west to the east side, cutting through several estates. The government decided to compensate owners of those estates, and to estimate the necessary expenses one should calculate the number of estates crossed by the highway.

Given the village size N and the coordinates of the points where the highway crosses eastern and western borders of the village, you must find the number of estates. You can assume, for the purpose of increasing the financial appeal of the highway project, that the highway is a straight line (i.e. has zero width). If the highway just touches the edge of an estate, it is still considered a crossing.

The highway is a line between points (0, W) and (100*N, E).

Input

In the input, there are three integers, N (1 <= N <= 100), W and E, (0 <= W, E <= 100*N) separated by spaces.

Process to the end of file.
Output

Output must contain a single integer - the number of estates crossed by the highway.
Sample Input

3 150 50
Sample Output

4

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
    • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
    • ¥15 Arcgis相交分析无法绘制一个或多个图形