HBC51045dd爱回文Visible Lattice Points题解

人生如戏 算法基础篇 70 0
挑战自我,勇攀编程高峰!全网最全C++题库,助您成为编程达人。
A lattice point (x,y) in the first quadrant , other than the origin, is visible from the origin if the line from to (x,y) does not pass through any other lattice point. For example, the point is not visible since the line from the origin passes through . The figure below shows the points (x,y) with 0 ≤x,y≤ 5 with lines from the origin to the visible points. Write a program which, given a value for the size,N, computes the number of visible points (x,y) with 0 ≤x,y≤N.

A lattice point (x, y) in the first quadrant (x and y are integers greater than or equal to 0), other than the origin, is visible from the origin if the line from (0, 0) to (x, y) does not pass through any other lattice point. For example, the point (4, 2) is not visible since the line from the origin passes through (2, 1). The figure below shows the points (x, y) with 0 ≤ x, y ≤ 5 with lines from the origin to the visible points. Write a program which, given a value for the size, N, computes the number of visible points (x, y) with 0 ≤ x, y ≤ N.

HBC51045dd爱回文Visible Lattice Points题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC51045dd爱回文Visible Lattice Points题解