#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void work(){
ll a,b,c;
cin>>a>>c;
if(a==c){
cout<<a<<'\n';
return;
}
if(c>a){
cout<<"-1\n";
return;
}
b=a>>1;
if(b==c){
cout<<b<<'\n';
return;
}
if(b<c*2){
cout<<"-1\n";
return;
}
ll m=b/c;
if(b/m==c){
cout<<b<<'\n';
return;
}
cout<<"-1\n";
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int T; cin>>T;
while(T--)work();
return 0;
}
这个能过 #7~#10,赛时我加上特判前6个点的暴力就过了