/*-----------------------------------------
zoj1003 Crashing Balloon
road 2007/08/31
dfs
--------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#define SWAP(x,y) do { x = x^y; y = x^y; x = x^y;} while(0)
typedef enum { FALSE, TRUE } boolean;
boolean flag;
boolean ans;
void search(int m, int n, int p)
{
#ifndef ONLINE_JUDGE
printf("search %d %d %d/n", m, n, p);
#endif
if (m==1 && n==1)
{
ans = TRUE;
return;
}
if (n==1)
flag = TRUE;
if (p>100) return;
if (m%p == 0)
search (m/p, n, p+1);
if (ans)
return;
if (n%p == 0)
search (m, n/p, p+1);
if (ans)
return;
search (m, n, p+1);
}
int main()
{
int m, n;
while(scanf("%d%d", &m, &n)!=EOF)
{
if (m<n)
SWAP(m,n);
ans = flag = FALSE;
search (m, n, 2);
if (!ans && flag)
printf("%d/n", n);
else
printf("%d/n", m);
}
}
zoj1003 Crashing Balloon
road 2007/08/31
dfs
--------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#define SWAP(x,y) do { x = x^y; y = x^y; x = x^y;} while(0)
typedef enum { FALSE, TRUE } boolean;
boolean flag;
boolean ans;
void search(int m, int n, int p)
{
#ifndef ONLINE_JUDGE
printf("search %d %d %d/n", m, n, p);
#endif
if (m==1 && n==1)
{
ans = TRUE;
return;
}
if (n==1)
flag = TRUE;
if (p>100) return;
if (m%p == 0)
search (m/p, n, p+1);
if (ans)
return;
if (n%p == 0)
search (m, n/p, p+1);
if (ans)
return;
search (m, n, p+1);
}
int main()
{
int m, n;
while(scanf("%d%d", &m, &n)!=EOF)
{
if (m<n)
SWAP(m,n);
ans = flag = FALSE;
search (m, n, 2);
if (!ans && flag)
printf("%d/n", n);
else
printf("%d/n", m);
}
}