ICPC Square
Time limit1sMemory limit2048 MB
Given N, D, and S, find the highest floor reachable from S by moving from floor x to a multiple y of x where y minus x is at most D.
- Level
Medium6 of 10
- Topics
- Number theory, Dynamic programming, Math
- Solved
- No attempts yet
Problem
ICPC Square is a hotel provided by the ICPC Committee for the accommodation of the participants. It has floors, numbered from 1 to . The hotel has an unusual elevator. A person on floor can ride the elevator once to floor if and only if is a multiple of and .
You are currently on floor . You can ride the elevator zero or more times. Find the highest floor you can reach.
Input
A single line contains three integers , , and (; ; ).
Output
Print a single integer, the highest floor you can reach by riding the elevator zero or more times.