View Code of Problem 66

#include<iostream>
#include<map>
#include<sstream>
#include<vector>
using namespace std;
int gcb(int a,int b){
	if(b==0) return a;
	else return gcb(b,a%b); 
} 


int main(){
	int a,b;
	while(cin>>a>>b){
		if(a==b==1){
			printf("1\n");
		}else{
			int d=gcb(a,b);
		 a=a/d;
		 b=b/d;
		 
		 printf("%d/%d\n",a,b);
		}
		
	} 
	
	
	
		return 0;
}

Double click to view unformatted code.


Back to problem 66