1723. Reprogramming | |||||||||||
| |||||||||||
|
|
| |||||||||
Time Limit: 1sec Memory Limit:32MB Description Recently Doctor Guan has discovered two new kinds of bacteria and named them BT-U and BT-V .BT-U and BT-V are quite special, they can only live with the help of each other. Doctor Guan did several experiments on BT-U and BT-V, here’re the results: Input There’re multiple cases. For each case there’s one line containing two integers for x and y. Input is end with two 0s. Output For each case output the result in a single line. Sample Input Copy sample input to clipboard 2 2 1 1 0 0 Sample Output 2 1 |
// Problem#: 1723
// Submission#: 1986097
// The source code is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License
// URI: http://creativecommons.org/licenses/by-nc-sa/3.0/
// All Copyright reserved by Informatic Lab of Sun Yat-sen University
#include<iostream>
#include<stdio.h>
int gcd(int a ,int b){
int temp;
while(b!=0){
temp = a%b;
a = b;
b = temp;
}
return a;
}
using namespace std;
int main(){
int n;
int a,b;
cin>>a>>b;
while(a>0 && b>0){
cout<<gcd(a,b)<<endl;
cin>>a>>b;
}
return 0;
}