See GCD again for hdu2504

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.