Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:建议用高精度,这题不要偷懒,附AC代码

Posted by himemeizhi at 2012-07-27 21:22:38 on Problem 1131
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator