Nine degrees OJ 1056 greatest common divisor

Source: Internet
Author: User
Tags greatest common divisor

Topic 1056: Greatest Common divisor

time limit:1 seconds

Memory limit:32 MB

Special question: No

submitted:4771

Resolution:3097

Title Description:

Enter two positive integers to greatest common divisor.

Input:

There are several groups of test data, with two positive integers entered per group.

Output:

For each set of inputs, output its greatest common divisor.

Sample input:
49 14
Sample output:
7

#include <stdio.h>int x (int a,int b) {    if (a%b==0) return B;    else        return x (b,a%b);} int main (int argc, char *argv[]) {    int m,n;  freopen ("In.txt", "in", stdin);    while (scanf ("%d%d", &m,&n)!=eof)    {        if (m>n)            printf ("%d\n", X (M,n));        else            printf ("%d\n", X (N,m));    }    return 0;} /**************************************************************    problem:1056    user:kirchhoff    Language:c    result:accepted    time:0 ms    memory:912 kb*********************************************** *****************/



Nine degrees OJ 1056 greatest common divisor

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.