Jabir is a merchant in ancient Persia, traveling a through the desert on camelback with a caravan of other merchants and travelers on a long journey. Suddenly a sandstorm begins to rage and Jabir loses sight of the rest of the caravan in the storm. Once the dust settles, Jabir doesn't see any of this fellow travelers, finding himself alone in the desert with only his own camel. After searching around a bit he manages to find some bags of grain (intended as camel food) which were scattered around by the storm, but nothing else.
Jabir begins to think. Judging from the position of the sun he can figure out which way is East - which happens to be exactly the direction of the nearest city. He's not sure exactly how many days away he is, but he guesses it is probably at least a few days' journey reamaining. However the desert is so large that there's no hope that anybody will happen to come across Jabir by happenstance. He has quite a bit of his own food and water to survive, but he will not be able to rely on help coming to him - he must form a plan to get back to civilization on his own.
He knows that his camel will travel 10 farsakhs (rougly
equal to 50 kilometers or 30 miles) for each 1 bag of grain she eats,
and this ratio scales linearly for any fractional amount - that is, she would travel 5 farsakhs while
eating 0.5 bags of grain, or 1 farsakh while 0.1 bags of grain.
He has gathered together the n bags of grain he found in a big pile, but his camel can
only carry a maximum of 1 bag of grain at a time.
Initially it looks like Jabir is unable to travel more than 10 farsakhs from his
current position, but then he starts to formulate an idea.
n grain bags, which we will call point A.1 bag of grain and travels East until the camel has eaten 1/3 of the bag. This is point B.2/3 bag of grain remaining, he leaves 1/3 at point B, then travels back to point A using the remaining 1/3 bag to feed his camel.1 bag of grain and travels East until the bag is 1/3 empty, again reaching point B.1/3 bag of grain he had previously left at that spot.B by 10 farsakhs more, having used a total of 2 bags of grain to travel rougly ~13.333 farsakhs!Although, at the end of the journey Jabir and his camel will be without any grain
and far from the pile of bags at point A, leaving him stranded. He begins to
wonder about the best way to strategically utilize his limited supply of n
bags of grain to maximize the total distance he can travel towards the nearest
city, and therefore maximize his chances of survival.
If Jabir has n bags of grain in a pile, his camel can only carry up to 1 bag of
grain at a time, and he has the option to drop or pick up any fractional amount of
grain at any point, how far can he potentially travel from his current spot?
Also understand that the camel cannot "pre-eat" food to cover distance. Imagine the camel continuously eating fractional amounts of grain for each fractional distance being travelled at any given moment.
Input Data
First line will be Q, the quantity of testcases.
Q lines will follow each with a single integer n.
Answer
Should consist of Q space-separated decimals, corresponding to the maximum amount
of farsakhs that Jabir could travel from his current spot.
Error should be less than 1e-6.
Example
input data:
4
1
2
3
786
answer:
10 13.333333 15.333333 43.152334