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

JAVA怎么WA了呢?

Posted by cisjiong at 2010-05-22 21:43:11 on Problem 2365
WA了无数次,哪里错了?
import java.util.Scanner;
import java.text.*;
public class Main{
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        DecimalFormat df=new DecimalFormat("#.00");
        int n=cin.nextInt();
        double r=cin.nextDouble();
        double res=0;
        double[] x=new double[n];
        double[] y=new double[n];
        x[0]=cin.nextDouble();
        y[0]=cin.nextDouble();
        for(int i=1;i<n;i++)
        {
            x[i]=cin.nextDouble();
            y[i]=cin.nextDouble();
            res+=Math.sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
        }
        res+=Math.sqrt((x[n-1]-x[0])*(x[n-1]-x[0])+(y[n-1]-y[0])*(y[n-1]-y[0]));
        res+=2*Math.PI*r;
        System.out.println(df.format(res));
    }
}

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