View Code of Problem 66

#include <bits/stdc++.h>
using namespace std;
int main(){
	long long a,b;
	while(cin>>a>>b){
		for(int i=2;i<=min(a,b);i++){
			if(a%i==0&&b%i==0) a/=i,b/=i;
		}
		if(a==b) cout<<1<<endl;
		else cout<<a<<"/"<<b<<endl;
	}
} 

Double click to view unformatted code.


Back to problem 66