URI Online Judge Solution 1170 Blobs Using C, Python Programming Language.
On the planet Alpha lives the creature Blobs, that eats just half of its supply of food available all day. Write an algorithm that reads the initial capacity of the food supply (in Kg), and calculate how many days will pass before Blobs eat all this supply until left a kg or less.
Input
The first line of the input contains a single integer N (1 ≤ N ≤ 1000), indicating the number of test cases. Each test case contains a single floating-point number X (1 ≤ X ≤ 1000), indicating the amount of food available for Blobs.
Output
For each test case, print one line containing the number of days that blobs will take to eat all their food supply, followed by the word "dias" that means days in portuguese.
Input Sample | Output Sample |
3 | 6 dias |
Solution Using Python:
T = int(input())
D = 0
while T>0:
N = float(input())
while True:
N = N/2
if N<=1.00:
D += 1
print("%d dias" % D)
D=0
break
D += 1
T-=1
Comments
Post a Comment