Spectator Seats
Time limit1sMemory limit64 MB
Print the number of seats on circles D1 to D2 with no other seat on the same ray from the center.
- Level
Medium6 of 10
- Topics
- Number theory, Math, Geometry
- Solved
- No attempts yet
Problem
The seats of a concert hall sit on concentric circles whose radii are positive integers, centered on the stage in the middle. The circle of radius 1 holds 1 seat, the circle of radius 2 holds 2 seats, and in the same way the circle of radius holds seats. The seats on one circle are spaced evenly, and every circle has one seat exactly north of the stage.
This performance uses only the seats on the circles whose radius is at least and at most . Treating each seat as a point, a seat is left unused when a seat closer to the stage in the same direction hides the center of the stage from it. Every seat that is not hidden is used. Only the seats on the circles used for this performance, that is the circles of radius to , can hide another seat.

The figure shows the seats and their use for and . The numbers are the radii of the circles, ● is a seat used for the performance, and ⊗ is a seat that is not used.
Write a program that reads the two radii and and prints how many seats are used.
Input
The first line contains the radii and as positive integers separated by a space, with .
Output
Print the number of seats that are used as a single positive integer.