ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Обсуждение задачи 1020. Ниточка

что не так?
Послано Kovalyshyn Artur 9 фев 2017 18:15
import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * Created by user on 06.02.2017.
 */
public class nytka {
    public static void main(String[] args) {
        double c = 0;
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        int b = Integer.valueOf(a);
        String q = sc.next();
        double r = Double.valueOf(q);
        double[] x = new double[b];
        double[] y = new double[b];
        if (100>b) {
            if (b > 0){
                for (int i = 0; i <= b - 1; i++) {
                    String x2 = sc.next();
                    double x1 = Double.valueOf(x2);
                    x[i] = x1;
                    String y2 = sc.next();
                    double y1 = Double.valueOf(y2);
                    y[i] = y1;

                }
                for (int i = b - 1; i > 0; i--) {
                    double rez = Math.sqrt(((x[i] - x[i - 1]) * (x[i] - x[i - 1])) + ((y[i] - y[i - 1]) * (y[i] - y[i - 1])));
                    c = c + rez;
                }
            }
        }
        double end = Math.sqrt(((x[b-1]-x[0])*(x[b-1]-x[0]))+((y[b-1]-y[0])*(y[b-1]-y[0])));
        c = c + end;
        double rad = (Math.PI*r*r)*(b/2);
        double endrez = c + rad;
        DecimalFormat f = new DecimalFormat("#,##0.00");
        System.out.print(f.format(endrez));
    }
}
Re: что не так?
Послано ToadMonster 9 фев 2017 19:16
You should clarify error - WA/TLE/runtime; and show test number.

b can be 100 by task description.
b can be 1 by task description.

Conditions like "if (b correct) then solve else do nothing" are useless.
Ok, you found b==102. So what? How should you check if WA is because program mistake or because you detected invalid b?

Usually if input data can be invalid then some specific program behavior is declared and required.
Here - on timus - input is supposed to be always valid, no any input-error-behavior expected.
You should fail program in specific way (different from regular WA) this case or remove condition at all.

Edited by author 09.02.2017 19:21