atcoder#RELAY2C. Garden
Garden
Score : points
Problem Statement
In your garden, there is a long and narrow flowerbed that stretches infinitely to the east. You have decided to plant kinds of flowers in this empty flowerbed. For convenience, we will call these kinds of flowers Flower . Also, we will call the position that is centimeters from the west end of the flowerbed Position .
You will plant Flower as follows: first, plant one at Position , then plant one every centimeters endlessly toward the east. That is, Flower will be planted at the positions Note that more than one flower may be planted at the same position.
Find the position at which the -th flower from the west is planted. If more than one flower is planted at the same position, they are counted individually.
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
When the -th flower from the west is planted at Position , print the value of . (The westmost flower is counted as the -st flower.)
2 6
20 10
25 15
50
Two kinds of flowers are planted at the following positions:
- Flower : Position
- Flower : Position
The sixth flower from the west is the Flower planted at Position . Note that the two flowers planted at Position are counted individually.
3 9
10 10
10 10
10 10
30
Three flowers are planted at each of the positions Thus, the ninth flower from the west is planted at Position .
1 1000000000
1000000000000000000 1000000000
1999999999000000000