See GCD again Time Limit: 1000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 9984 accepted submission (s): 4157
Problem description has three positive integers A, B, C (0 <a, B, c <10 ^ 6), where C is not equal to B. If the maximum common divisor of A and C is B, A and B are known, and the minimum C that meets the condition is obtained.
Input N in the first line indicates that there are N groups of test data. In the next n rows, two positive integers A and B are entered in each line.
Output corresponds to C, and each group of test data occupies one row.
Sample Input
26 212 4
Sample output
48
Source
# Include <stdio. h> int gcd (int A, int B) {return B? Gcd (B, A % B): A;} int main () {int N, A, B, C; scanf ("% d", & N ); while (n --) {scanf ("% d", & A, & B); For (C = B <1; C ++ = B) {If (gcd (a, c) = B) break;} printf ("% d \ n", c);} return 0 ;}
See GCD again for hdu2504