zoukankan      html  css  js  c++  java
  • 判断两个数是否互质

    Problem Description

     输入两个整数,判断他们是否互质。

    Input

     两个整数。(多组数据)

    Output

     如果他们互质,则输出“yes”,否则,输出“no”。

    Sample Input

    2 3

    Sample Output

    yes
    




    #include <iostream>

    using namespace std;
    int mgcd(int a,int b)
    {
        int t;
        if(a<b)
        {
            t=a;a=b;b=t;
        }
        while(a%b)
        {
            t=b;
            b=a%b;
            a=t;
        }
        return b;
    }
    int main()
    {
        int a,b;
        while(cin>>a>>b)
        {
            if(mgcd(a,b)==1)
            {
                cout<<"yes"<<endl;
            }
            else
            {
                cout<<"no"<<endl;
            }
        }
        return 0;
    }


  • 相关阅读:
    supervisor管理airflow
    airflow迁移
    flume部署
    canal原理&部署
    EMR日常操作
    linux的route
    autossh
    Velocity(5)——#macro 指令
    Git(1)----Eclipse安装Git插件
    Velocity(4)——引入指令和#Parse 指令
  • 原文地址:https://www.cnblogs.com/yldf/p/6249935.html
Copyright © 2011-2022 走看看