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

Обсуждение задачи 1001. Обратный корень

[PYTHON] Can anyone please tell me why this gives wrong answer on test 1? It works fine with my compiler fo a lot of cases.
Послано rayneh 18 июл 2019 02:45
import math
import re

input_string =  ''

while True:
    line = input()
    if line:
        input_string = input_string + ' ' + line
    else:
        break


input_digits = [int(x) for x in input_string.replace('\n',' ').replace('\t', ' ').split()]
input_digits = input_digits[::-1]

for int in input_digits:
        sqr_root = math.sqrt(int)
        print(format(sqr_root, '.4f'))



#Thanks for the help guys!
Re: [PYTHON] Can anyone please tell me why this gives wrong answer on test 1? It works fine with my compiler fo a lot of cases.
Послано VioletVal 12 авг 2019 10:01
I tested your code on some online compilers, and the last two answers were printed, but not the first two. It looks like your algorithm correctly read the first line, but because there were empty lines for the next couple lines, your break statement kept the code from reading the last two lines in the example testcase. You need to change the code so it can read all the lines, even the ones that come after empty lines.