解題思路:
推出的公式為 N / (M ^ (N-1) )。要用到高精度
import java.util.*;
import java.io.*;
import java.math.*;
public class Main
{
static BigInteger gcd(BigInteger a, BigInteger b)
{
if(b.equals(BigInteger.ZERO)) return a;
else return gcd(b, a.mod(b));
}
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
int T, N, M;
T = cin.nextInt();
for(int i=1;i<=T;i++)
{
M = cin.nextInt();
N = cin.nextInt();
BigInteger tmp1 = BigInteger.valueOf(N);
BigInteger tmp2 = BigInteger.valueOf(M).pow(N-1);
BigInteger t = gcd(tmp1, tmp2);
tmp1 = tmp1.divide(t);
tmp2 = tmp2.divide(t);
System.out.println(tmp1 + "/" + tmp2);
}
}
}