CUTCAKE - Eat all the brownies !
BrownieDude was given the job of cutting cake at a party for serving the guests. But BrownieDude is both lazy and hungry, so he wants to cut the cake into maximum number of pieces with minimum number of cuts and go off to eating brownies.
The host of the party says that BrownieDude can cut the cake into unequal pieces but cannot cut in more than one plane.(Only vertical cuts are allowed.) Given the number of guests, find the number of cuts sufficient to generate the cake pieces.
First line contains 't', the number of test cases. 't' lines follow. (1 <= t <= 1000)
Each line denotes the number of guests. (1 <= n <= 10^11)
One number denoting the number of cuts.
Note: It is guaranteed that an integer solution will always exist.
2 1 2
Explanation for test cases: If there is only one guest, there is no need to cut the cake. If there are 2 guests, the cake can be cut into 2 pieces in 1 cut.
and finally!!!!!!!!........... 100th AC in spoj classic ;)
pancake cutting problem...
Division of a plane by n lines. Simple. :)
found this link very useful
my 50th :
you can not rearrange the pieces for cuttingLast edit: 2015-12-14 13:09:30
(Tjandra Satria Gunawan)(æ›¾æ¯…æ˜†):
"Only vertical cuts are allowed" this is misleading statement. got AC after assuming "only straight line cuts are allowed", straight line cut not necessarily vertical, it can be horizontal, diagonal, etc too..
use long long ...long is giving wrong answer .