全TLE球条
查看原帖
全TLE球条
658198
gesong1234楼主2024/5/26 11:28
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=100;
inline int read(){
	char c=getchar();
	int f=1,ans=0;
	while(c<48||c>57) f=(c==45?f=-1:1),c=getchar();
	while(c>=48&&c<=57) ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans*f;
}
inline int sum(int x){
	if (x==-1) return 0; 
	if (x==0){
		puts("? 0 0");fflush(stdout);
		int x=read();
		if (x==-1) exit(0);
		return x;
	}
	x++;
	int xxx=x;
	int ans=0;
	int s=1,cnt=0;
	while(x%2==0) s*=2,x/=2,cnt++;
	int ss=xxx/s;
	printf("? %lld %lld\n",cnt,ss-1);
//	cout <<"? "<<cnt<<" "<<ss-1<<endl;
	fflush(stdout);
	ans=read();
	if (ans==-1) exit(0);
	int zd=s*(ss-1);
	for (int i=0;(1<<(i+1))<=zd;i++){
		printf("? %lld %lld\n",i,1);
	///	cout <<"? "<<i<<" 1"<<endl;
		fflush(stdout);
		int x=read();
		if (x==-1) exit(0);
		ans=(ans+x)%mod;
	}
	puts("? 0 0");fflush(stdout);
	x=read();
	if (x==-1) exit(0);
	ans=(ans+x)%mod;
	return ans;
}
main(){
	int n=read(),l=read(),r=read();
	cout <<"! "<<(sum(r)-sum(l-1)+mod)%mod<<endl;fflush(stdout);
    return 0;
}
2024/5/26 11:28
加载中...