1648:Countryside Highway

题目描述
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).

输入解释
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 must contain a single integer - the number of estates crossed by the highway.
输入样例
3 150 50
输出样例
4

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-1648

最后修改于 2020-10-29 06:09:58 UTC 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536

·

·

·

·

登陆或注册以提交代码