poj1131
高精度
View Code
import java.io.*; import java.util.*; import java.math.*; public class Main { public static void main(String[] args) throws FileNotFoundException { // Scanner cin = new Scanner(new FileInputStream("t.txt")); Scanner cin = new Scanner(System.in); while (cin.hasNext()) { String st = cin.next(); BigDecimal a = new BigDecimal("0"); BigDecimal b = new BigDecimal("1"); for (int i = 2; i < st.length(); i++) { b = b.multiply(BigDecimal.valueOf(8)); a = a.add(BigDecimal.valueOf(st.charAt(i) - '0').divide(b)); } System.out.println(st + " [8] = " + a + " [10]"); } } }