使用內建函數

 

或輾轉相除法

 

#include <iostream>
#include <algorithm>

 

 

using namespace std;

int main()
{
    int a, b;

    while(cin >> a >> b)
        cout << __gcd(a,b) << endl;
        
    return 0;
}

arrow
arrow
    全站熱搜

    大神(偽) 發表在 痞客邦 留言(0) 人氣()