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 |
JAVA怎么WA了呢?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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator