| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:建议用高精度,这题不要偷懒,附AC代码In Reply To:建议用高精度,这题不要偷懒,附AC代码 Posted by:scuwf at 2012-02-11 20:07:25 import java.io.*;
import java.util.*;
import java.math.*;
class Main
{
static BigDecimal a,c;
static BigInteger b;
static int p,i;
static public void main(String[] args)
{
Scanner in=new Scanner(System.in);
while(in.hasNext())
{
a=in.nextBigDecimal();
System.out.print(a);
System.out.print(" [8] = ");
p=a.scale();
a=a.multiply(BigDecimal.valueOf(Math.pow(10,p)));
b=a.toBigInteger();
Scanner in1=new Scanner(b.toString());
b=in1.nextBigInteger(8);
a=new BigDecimal(b);
c=new BigDecimal(Math.pow(8,p));
System.out.print(a.divide(c));
System.out.print(" [10]\n");
}
}
}
(偷懒望天……
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator