Masala B

Xotira 32 MB Vaqt 1000 ms
14

ICPC Square

ICPC Square is a hotel provided by the ICPC Committee for the accommodation of the participants. It consists of NN floors (numbered from 11 to NN). This hotel has a very unique elevator. If a person is currently at floor xx, by riding the elevator once, they can go to floor yy if and only if yy is a multiple of xx and yxDy−x≤D.

You are currently at floor SS. You want to go to the highest possible floor by riding the elevator zero or more times. Determine the highest floor you can reach.


Kiruvchi ma'lumotlar:

A single line consisting of three integers N D S(2N1012;1DN1;1SN).N  D  S (2≤N≤1012;1≤D≤N−1;1≤S≤N).


Chiquvchi ma'lumotlar:

Output a single integer representing the highest floor you can reach by riding the elevator zero or more times.


Misollar
# input.txt output.txt
1
64 35 3
60
2
2024 2023 1273
1273
Izoh:

Explanation for the sample input/output #1

First, ride the elevator from floor 3 to floor 15. This is possible because 15 is a multiple of 3 and 15−3≤35. Then, ride the elevator from floor 15 to floor 30. This is possible because 30 is a multiple of 15 and 30−15≤35 Finally, ride the elevator from floor 30 to floor 60. This is possible because 60 is a multiple of 30 and 60−30≤35.