ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1020. Rope

Problem with Java
Posted by Van_Veber 6 Aug 2009 01:49
Code
=================================================================
import java.util.*;
import java.io.*;

public class t1020
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);

int N = in.nextInt();
Double R = in.nextDouble();

Double[] x = new Double[N];
Double[] y = new Double[N];

double len = 2 * Math.PI * R;

for(int i = 0; i < N; i ++)
{
x[i] = in.nextDouble();
y[i] = in.nextDouble();
}

for(int i = 0; i < N - 1; i ++)
len += Math.sqrt(Math.pow((x[i] - x[i == 0 ? N - 1 : i - 1]), 2) + Math.pow((y[i] - y[i == 0 ? N - 1 : i - 1]), 2));

out.println(len);
out.flush();
}
}
================================================================
Write:
================================================================
4 1.0
Exception in thread "main" java.util.InputMismatchException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextDouble(Unknown Source)
at t1020.main(t1020.java:12)
=================================================================
Why I can not read 1.0?!
4 1 -- Read correctly!!!