#include<stdio.h> int gcd(long x, long y) { long temp; if(x > y) { temp=x; x=y; y=temp; } temp=y%x; while(temp!=0) { y=x; x=temp; temp=y%x; } return x; } int main() { long a, b; while(scanf("%d %d", &a, &b)!=EOF) { if(a<b) { long c=gcd(a, b); printf("%d/%d\n", a/c, b/c); }else if(a==b) printf("%d\n", 1); } } |
Double click to view unformatted code.