#D11119. SNS
SNS
SNS
Problem statement
AOR Ika-chan is in a bad mood lately. Apparently, I don't like the ratio of the number of followers to the number of followers of "Ikatta". Currently, AOR Ika-chan has followers, followers, and a ratio of .
Therefore, AOR Ika decided to increase or decrease the number of followers so that the ratio of the number of followers to the number of followers would be an integer ratio that she liked. The integer ratio I like is a ratio that can be expressed so that both values included in the ratio are integers of or more and or less.
However, AOR Ika doesn't want to change the number of followers as much as possible, so I want to make the absolute value of the difference from before the change as small as possible. Create a program that asks at least how many followers you need to change to make AOR Ika feel good.
Input constraints
sample
Sample input 1
19 30 3
Sample output 1
1
Sample input 2
3 7 7
Sample output 2
0
Sample input 3
3 7 1
Sample output 3
Four
Sample input 4
102 30 3
Sample output 4
12
By reducing the number of followers by , it becomes , and the higher ratio number is or less. At this time, the amount of change is .
Sample input 5
3 4 2
Sample output 5
1
If you unfollow one person, it will be , and if you follow it, it will be . In both cases, the absolute value of increase / decrease is , which is the answer.
Sample input 6
1 100 2
Sample output 6
49
Please note that at least people must be following.
input
output
Output the minimum absolute value of the amount of change in , which can be an integer ratio you like.
Example
Input
19 30 3
Output
1
inputFormat
Input constraints
sample
Sample input 1
19 30 3
Sample
outputFormat
output 1
1
Sample input 2
3 7 7
Sample output 2
0
Sample input 3
3 7 1
Sample output 3
Four
Sample input 4
102 30 3
Sample output 4
12
By reducing the number of followers by , it becomes , and the higher ratio number is or less. At this time, the amount of change is .
Sample input 5
3 4 2
Sample output 5
1
If you unfollow one person, it will be , and if you follow it, it will be . In both cases, the absolute value of increase / decrease is , which is the answer.
Sample input 6
1 100 2
Sample output 6
49
Please note that at least people must be following.
input
output
Output the minimum absolute value of the amount of change in , which can be an integer ratio you like.
Example
Input
19 30 3
Output
1
样例
19 30 3
1