帮@tasho11y问的。 \
#include<bits/stdc++.h>
using namespace std;
long long n,k,ans,kk;
void solve(){
cin>>n>>k;
ans=0;
if(n==k){
cout<<"?1"<<endl;
cout.flush();
cin>>ans;
if(ans==-1)exit(0);
}
else{
int i;
for(i=1;i<=n-k+1;i+=k){
cout<<"?"<<i<<endl;
cout.flush();
cin>>kk;
if(kk==-1)exit(0);
ans^=kk;
}
if(n%k!=0){
cout<<"?"<<i-k+(n%k)/2<<endl;
cout.flush();
cin>>kk;
if(kk==-1)exit(0);
ans^=kk;
cout<<"?"<<n-k+1<<endl;
cout.flush();
cin>>kk;
if(kk==-1)exit(0);
ans^=kk;
}
}
cout<<"!"<<ans<<endl;
cout.flush();
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long T;cin>>T;
while(T--)solve();
return 0;
}
感觉是交互库那一段没写对。