//ABcDexter
#include<bits/stdc++.h>
using namespace std;
int i,n,t;
int ans= 0 ;
const int INF= 2 << 19 ;
int Solve( int n,int i, int x) //greedy approach, MUST FIND DP!
{
if ( n== x) { //cout<<"reached at x: "<<n<<","<<i<<","<<x<<endl;
return ans= i- 1 ; }
else
if ( n< - x) return INF;
else if ( n> 2 * x) return INF;
else { //cout<<"here: "<<n<<","<<i<<","<<x<<endl;
return ans= min( Solve( n+ i,i+ 1 ,x) , Solve( n- i,i+ 1 ,x) ) ;
}
}
int main( )
{ //int ans=0;
//cout<<INF;
for ( cin >> t; t; t-- )
{ ans= 0 ;
cin >> n;
cout << ">! For x=" << n<< ", ans : " << Solve( 0 ,0 ,n) << endl;
}
}
Ly9BQmNEZXh0ZXIKI2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKIAppbnQgaSxuLHQ7CmludCBhbnM9MDsKY29uc3QgaW50IElORj0yPDwxOTsKCmludCBTb2x2ZShpbnQgbixpbnQgaSwgaW50IHgpIC8vZ3JlZWR5IGFwcHJvYWNoLCBNVVNUIEZJTkQgRFAhCnsKCQoJaWYobj09eCkgeyAvL2NvdXQ8PCJyZWFjaGVkIGF0IHg6ICI8PG48PCIsIjw8aTw8IiwiPDx4PDxlbmRsOyAKCXJldHVybiBhbnM9aS0xO30KCQoJZWxzZQoJCWlmKG48LXgpIHJldHVybiBJTkY7CgkJZWxzZSBpZihuPjIqeCkgcmV0dXJuIElORjsKCQkKCQllbHNlIHsgLy9jb3V0PDwiaGVyZTogIjw8bjw8IiwiPDxpPDwiLCI8PHg8PGVuZGw7CgkJCXJldHVybiBhbnM9bWluKCBTb2x2ZShuK2ksaSsxLHgpLCBTb2x2ZShuLWksaSsxLHgpKTsKCQl9Cn0JCgppbnQgbWFpbigpCnsJLy9pbnQgYW5zPTA7CgkvL2NvdXQ8PElORjsKCWZvcihjaW4+PnQ7dDt0LS0pCgl7CWFucz0wOwoJCWNpbj4+bjsKCQljb3V0PDwiPiEgRm9yIHg9Ijw8bjw8IiwgYW5zIDogIjw8U29sdmUoMCwwLG4pPDxlbmRsOwoJfQp9
stdin
NTIKMQoyCjMKNAo1CjYKNwo4CjkKMTAKMTEKMTIKMTMKMTQKMTUKMTYKMTcKMTgKMTkKMjAKMjEKMjIKMjMKMjQKMjUKMjYKMjcKMjgKMjkKMzAKMzEKMzIKMzMKMzQKMzUKMzYKMzcKMzgKMzkKNDAKNDEKNDIKNDMKNDQKNDUKNDYKNDcKNDgKNDkKNTAKNTEKNTIK
52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
stdout
>! For x=1, ans : 1
>! For x=2, ans : 3
>! For x=3, ans : 2
>! For x=4, ans : 3
>! For x=5, ans : 5
>! For x=6, ans : 3
>! For x=7, ans : 5
>! For x=8, ans : 4
>! For x=9, ans : 5
>! For x=10, ans : 4
>! For x=11, ans : 5
>! For x=12, ans : 7
>! For x=13, ans : 5
>! For x=14, ans : 7
>! For x=15, ans : 5
>! For x=16, ans : 7
>! For x=17, ans : 6
>! For x=18, ans : 7
>! For x=19, ans : 6
>! For x=20, ans : 7
>! For x=21, ans : 6
>! For x=22, ans : 7
>! For x=23, ans : 9
>! For x=24, ans : 7
>! For x=25, ans : 9
>! For x=26, ans : 7