Nezord
Профи
(505)
1 месяц назад
def len_between_blok(n, k, l, p):
parking_block = 2 * k
count = 0
count_parking_blok = 0
while count <= n:
if n <= parking_block:
return '-1'
elif count < n:
count += parking_block
count_parking_blok += 1
elif count >= n:
break
len_parking_blok = 2 * p
len_all_parking_blok = count_parking_blok * len_parking_blok
if len_all_parking_blok > l:
return '-1'
else:
return l - len_all_parking_blok
# Ввод значений
try:
n, k, l, p = map(int, input("Введите значения n, k, l, p через пробел: ").split())
if n >= 1 and k >= 1 and l >= 1 and p >= 1:
print(len_between_blok(n, k, l, p))
else:
print('Ошибка, вы ввели одно или несколько значений, которые меньше 1.')
except ValueError:
print('Ошибка, неверный ввод. Убедитесь, что вводите только целые числа.')
def len_between_blok(n,k,l,p):
parking_block = 2 * k
count = 0
count_parking_blok = 0
while count <= n:
if n <= parking_block:
result = '-1'
return result
elif count < n:
count += parking_block
count_parking_blok += 1
elif count >= n:
break
else:
pass
len_parking_blok = 2 * p
len_all_parking_blok = count_parking_blok * len_parking_blok
if len_all_parking_blok > l:
print('-1')
else:
pass
result = l - len_all_parking_blok
return result
n,k,l,p = input().split()
n = int(n)
k = int(k)
l = int(l)
p = int(p)
if n >= 1 and k >= 1 and l >= 1 and p >=1:
print(len_between_blok(n,k,l,p))
else:
print('Ошибка, вы ввели одо или несколько значений, которые меньше 1.')
Ошибка программы:
Traceback (most recent call last):
File "./113649", line 29, in <module>
n,k,l,p = input().split()
File "<string>", line 1
10 3 27 5
^
SyntaxError: invalid syntax