代码:(c++)
#include<bits/stdc++.h>
using namespace std;
long long h,t;
bool f;
bool is_p(int x){
if(x<=1||x%2==0) return false;
for(int i=2;i*i<=x;i++){
if(x%i==0) return false;
}
return true;
}
int main()
{
cin>>t;
while(t--){
f=0;
cin>>h;
if(is_p(h)){
cout<<1<<endl;
continue;
}
for(int i=0,j=0;j<=h;j=j<<1|1,i++){
if(h-j==0){
cout<<i<<endl,f=1;
break;
}
if(is_p(h-j)){
cout<<i+1<<endl,f=1;
break;
}
}
if(!f) cout<<-1<<endl;
}
return 0;
}