#include <bits/stdc++.h>
using namespace std;
const int N = 50000;
bitset<N> a;
int b[N] = {0};
int res = 0;
int h;
bool check(int k)
{ int j = log2(h - k + 1);
return pow(2, j) == (h - k + 1);
}
void solve()
{
cin >> h;
int *p = lower_bound(b + 1, b + 1 + res, h);
if (*p == h)
{
cout << 1 << '\n';
return;
}
while (1)
{
p--;
if (check(*p))
{
if (*p)
cout << log2(h - *p + 1) + 1 << '\n';
else
cout << log2(h - *p + 1) << '\n';
return;
}
if (p == b)
{
cout << -1 << '\n';
return;
}
}
}
int main()
{
int t;
cin >> t;
for (int i = 2; i <= N; i++)
{
if (a[i] == 0)
b[++res] = i;
for (int j = 1; j <= res; j++)
{
if (b[j] * i > N)
break;
a[b[j] * i] = 1;
if (i % b[j] == 0)
break;
}
}
while (t--)
solve();
return 0;
}
看不了测试点,不知道哪里错,求波hack家人们