Flowers and Petals

0

0 votes
Medium-Hard
Problem

Ned has free time so he decide to play a game.In this game he take a random flower with n petals.He numbers the petals from 1 to n and pluck each petal until all the petals are fallen.He start with the first petal(petal with number 1),pluck it leaves the next and again pluck another and again leaves the next one and pluck another. He do it again an again until all the petals are plucked from the flower.

Input:

First line contains t, number of test cases.

Each t lines conatin n (number of petals).

Output:

Petal number plucked in the end of the game.

Constaints

1<=T<=10

2<=n<10^10

Sample Input
3
7
6
10
Sample Output
6
4
4
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For 7 petals flower

enter image description here

First he pluck the 1st petal

enter image description here

Leaves the 2nd petal and pluck 3rd petal

enter image description here

Leaves the 4th and pluck 5th petal

enter image description here

leaves 6th and pluck 7th petal

enter image description here

leaves the 2nd and pluck 4th

enter image description here

leaves 6th and pluck 2nd petal

enter image description here

at the end he pluck the 6th petal so output is 6.

Editor Image

?