one observation:

the pick at the end should always be n - (2^k - 1);

We can prove this with some tricky math....

```
class Solution {
public:
int getMoneyAmount(int n) {
int re[n+1];
int count[n+1];
re[0] = 0; count[0] = 0;
re[1] = 0;count[1] = 0;
re[2] = 1;count[2] = 1;
re[3] = 2;count[3] = 1;
re[4] = 4;count[4] = 2;
for(int i = 5; i <= n; i++)
{
int mintmp = INT_MAX;
int sum = 0;
for(int j = 2; j <= i; j*=2)
{
int tmp = max(i-j+1 + sum, re[i-j] + i-j+1);
sum+=i-j+1;
if(tmp < mintmp)
{mintmp = tmp;}
}
re[i] = mintmp;
}
return re[n];
}
};
```