Blobs(URI Online Judge | 1170)

URI Online Judge | 1170

Blobs

Adapted by Neilor Tonin, URI  Brazil
Timelimit: 1
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 SampleOutput Sample
3
40.0
200.0
300.0
6 dias
8 dias
9 dias
Solution:

#include<bits/stdc++.h>
using namespace std;
int main()
{
int i,t,day;
float supply;
cin>>t;
for(i=0;i<t;i++)
{
day=0;
cin>>supply;
while(supply>1)
{
supply=supply/2;
day++;
}
printf("%d dias\n",day);
}
}

Comments