MINCOUNT - Move To Invert

no tags 

A triangle made of coins of height h is as follows
It has h coins at the base and h-1 coins one level above base and so on.(Coins are placed as shown in the figure below)
And at the top most level there will be only one coin
Now given h the task is to invert this triangle by moving minimum number of coins. For example when h=4 triangle is
Invert
For h=4 at least 3 coins must be moved to invert it.

Input

In the first line N will be given and then N lines follow with each line having a integer which is the height of triangle in that test case.00≤h<1010;

Output

For each test case output in a seperate line the minimum number of moves required to invert the triangle. Output fits in long long data type

Example

Inputt:
1
3

Output:
2

hide comments
killerz: 2012-05-31 07:59:22

just a simple math :)
Good prob to show the fastness of printf/scanf over cin/cout

vD: 2012-03-23 12:51:04

Last edit: 2012-03-23 12:52:51
(^@_^@): 2012-02-06 14:30:14

uses simple mathematics
but remember to use printf, scanf("%lli").....
and submit with c compiler

codecracker: 2012-02-06 14:29:46

it uses very simple mathematics...........

Albert Chen: 2012-01-08 23:36:57

Yes... h can be 0.

MR. BEAN : 2011-12-12 14:31:56

answer for 100 is 1683 and for 10^10 is 7443294631478557525 !!!

sri: 2011-10-05 21:55:49

is the solution for 100 is 1875???
i am not getting 1683.
help me out.

Pavel Simo: 2011-07-22 08:46:37

weak test cases accepted with long long...

Vinay Chaudhary: 2011-07-21 21:15:41

WTH its not that complicated....analyse the output till 10 you will figure it out..:)..use scanf and printf instead of cin and cout

The Champ: 2011-07-16 10:16:12

why ERL is not allowed?


Added by:Abhilash I
Date:2006-12-16
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO
Resource:IIIT Hyderabad Local Programming Contest