hdu 4762 公式 java

n/(n)^(m-1)

 1 import java.io.*;
 2 import java.math.*;
 3 import java.util.*;
 4 
 5 public class Main {
 6     static BigInteger gcd(BigInteger a,BigInteger b)
 7     {
 8         if(b.equals(BigInteger.ZERO))return a;
 9         else return gcd(b,a.mod(b));
10     }
11     public static void main(String arg[])
12     {
13         int T;
14         int n,m;
15         Scanner cin = new Scanner(System.in);
16         T = cin.nextInt();
17         while( T > 0 )
18         {
19             m = cin.nextInt();
20             n = cin.nextInt();
21             BigInteger tmp1 = BigInteger.valueOf(n);
22             BigInteger tmp2 = BigInteger.valueOf(m).pow(n-1);
23             BigInteger tt = gcd(tmp1,tmp2);
24             tmp1 = tmp1.divide(tt);
25             tmp2 = tmp2.divide(tt);
26             System.out.println(tmp1+"/"+tmp2);
27             T--;
28         }
29     }
30 }
原文地址:https://www.cnblogs.com/cnblogs321114287/p/4777373.html