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

Why Runtime error on test 4??
Posted by FromNothingToFinal 31 Oct 2018 22:13
public class Problem {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int r = sc.nextInt();
        double l = 0;
        if (n != 1) {
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();
        double memoryX = x1, memoryY = y1;
        for (int i = 1; i <= n; i++) {
            if (i == n) {
                l += Math.sqrt((memoryX - x1) * (memoryX - x1) + (memoryY - y1) * (memoryY - y1));
                continue;
            }
            double x = sc.nextDouble();
            double y = sc.nextDouble();
            l += Math.sqrt((x - memoryX) * (x - memoryX) + (y - memoryY) * (y - memoryY));
            memoryX = x;
            memoryY = y;
        }
        }
        l += 2*Math.PI*r;
        System.out.printf("%.2f", l);
        sc.close();
    }

}
Re: Why Runtime error on test 4??
Posted by roman velichkin 10 Nov 2019 19:07
radius can be float number