java高精度尝试,
poj2109,比较坑的题目
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); BigInteger mod = BigInteger.valueOf(1); while(in.hasNext()) { int k = in.nextInt(); BigInteger y = in.nextBigInteger(); BigInteger l = BigInteger.valueOf(1); BigInteger r = y; BigInteger mid, ans; while(l.compareTo(r) == -1){ mid = (l.add(r)).divide(BigInteger.valueOf(2)); ans = BigInteger.valueOf(1); int temp = k; while(temp != 0){ ans = ans.multiply(mid); temp = temp - 1; } if(ans.compareTo(y) == -1) l = mid.add(BigInteger.valueOf(1)); else r = mid; } ans = BigInteger.valueOf(1); int temp = k; while(temp != 0){ ans = ans.multiply(l); temp = temp - 1; } if(ans.compareTo(y) == 1) l = l.subtract(BigInteger.valueOf(1)); System.out.println(l); } } }