Quick actions

cmd+k|ctrl+k

Navigation

Languages

Winne

Snippet info

Language

Python

Visibility

public

Author

tim85145

Created

2020-05-13T13:03:20Z

Updated

2020-05-13T13:03:20Z

from decimal import Decimal, ROUND_HALF_UP

cases = int(input())

for x in range(cases):
	H, U, D, F = input().split(' ')
	H, U, D, F = int(H), int(U), int(D), int(F)
	down = Decimal(U*F/100).quantize(Decimal('.0'), ROUND_HALF_UP)
	times, height  = 1, U
	while True:
		height = height + U - D - (down*times)
		times += 1
		if height >= H:
			break
		if height < 0:
			times = 0
			break

	if times == 0:
		hour = 0
	else:
		hour = Decimal(times) + Decimal((times-1)/2)

	print(hour)
INFO