123
地址: http://acm.hdu.edu.cn/showproblem.php?pid=6288
嗯嗯, 数据出的很好, 精度控制的非常不错 卡 log 函数向上取整精度, 所以 需要 自己写 log2 函数 , 2 的多少次方 接近 n
JAVA
import java.math.BigInteger;
import java.util.Scanner;
import java.lang.Math;
public class Main {
public static BigInteger a, b, k;
public static BigInteger one = BigInteger.ONE;
public static BigInteger zero = BigInteger.ZERO;
public static BigInteger two = BigInteger.valueOf(2);
public static void main(String[] args) {
int t;
Scanner cin = new Scanner(System.in);
t = cin.nextInt();
while (t-- != 0) {
a = cin.nextBigInteger();
b = cin.nextBigInteger();
k = cin.nextBigInteger();
BigInteger l = one;
BigInteger r = new BigInteger("1000000000000000000000");
BigInteger ans = one;
while (l.compareTo(r) <= 0) {
BigInteger mid = l.add(r).divide(two);
BigInteger q = mid.pow(a.intValue()); // n^a
int cot = 1; // log2n
BigInteger log = two;
while (log.compareTo(mid) < 0) {
cot++;
log = log.multiply(two);
}
BigInteger p = q.multiply( BigInteger.valueOf(cot).pow(b.intValue()) ); // log2n ^b
if( p.compareTo(k)<=0)
{
l = mid.add(one);
ans = mid;
}
else
{
r = mid.subtract(one);
}
}
//System.out.println(l.subtract(one));
System.out.println(ans);
}
}
}