#include "stdio.h" #include "math.h" #include "string.h" int main() { int a,b; int x,y; int r; for(;scanf("%d%d",&a,&b)!=EOF;) { if(a==b) { printf("1\n");continue;} x=a; y=b; r=a%b; for(;r!=0;) { a=b; b=r; r=a%b; } printf("%d/%d\n",x/b,y/b); } } |
Double click to view unformatted code.