您的位置:首页 > 其它

HDU 4762 Cut the Cake (高精度 + 公式)

2015-09-09 19:23 393 查看
可得公式: n / (m^(n-1))

import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int t = sc.nextInt();
for (int i = 0; i < t; ++i) {
int m = sc.nextInt();
int n = sc.nextInt();
BigInteger s = BigInteger.valueOf(n);
BigInteger a = BigInteger.valueOf(m).pow(n - 1);
BigInteger g = a.gcd(s);
//System.out.println(g);
System.out.println(s.divide(g) + "/" + a.divide(g));

}

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: