标签:blog http io ar java for on div 2014
题目链接:传送门
题意:小数八进制转成10进制。。BigDecimal水过去。。
import java.io.*; import java.util.*; import java.math.*; import java.text.*; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); String s; while(in.hasNext()){ s=in.next(); int len=s.length(); BigDecimal ans=BigDecimal.ZERO; for(int i=2;i<len;i++){ BigDecimal a=new BigDecimal(s.charAt(i)-'0'); BigDecimal b=new BigDecimal(8); ans=ans.add(a.divide(b.pow(i-1))); } System.out.println(s+" [8] = "+ans+" [10]"); } } }
标签:blog http io ar java for on div 2014
原文地址:http://blog.csdn.net/qq_16255321/article/details/41423003