Question 1: The same remainder problem
Three positive integers a, b, c are known.
Given an integer x greater than 1, divide a, b, and c with it as the divisor, and the remainders will be the same.
What is the minimum value of x that satisfies the above conditions?
The data guarantees that x has a solution.
Input
a line, three positive integers a, b, c not greater than 1000000, separated by a space between the two integers.
Output
An integer, the smallest value of x that satisfies the condition.
Sample input
300 262 205
Sample output
19
This problem can be solved by iterating over the possible divisors x. We can start from 2 and try one by one until we find an x that satisfies the condition.
The specific solution ideas are as follows:
(1) Input three positive integers a, b, c.
(2) Start traversing the divisor x from 2.
(3) For each x, calculate the remainders of dividing a, b, and c by x.
(4) If the three remainders are equal, output x and end the program.
(5) If no x that satisfies the condition is found after traversing all possible x values, according to the requirements of the topic, this situation will not happen.
The following is the code implemented in C language:
<