标签:链接 sum 距离 ++ lld contest check https poi
题目链接
中石油补题
给出你2n2n的方阵,让你从其中选出nn个点,使得他们两两点的距离不是根号下a也不是根号下b
首先我们看两点之间的距离:设两点x为x轴差,y为y轴差,那么我们之间的距离:
那么我们对其\(dis^2\)进行分析
void check(ll res){
	ll tot=0;
	///余数为0
	while(!(res%4)) res>>=2,++tot;
	///余数为 1 
	if(res&1){
		for(ll i=0;i<n*2;i++){
			for(ll j=0;j<n*2;j++){
				if(((i>>tot)+(j>>tot))&1) dp[i][j]=1;
			}
		}
		return ;
	}
	///余数为2
	/// 没有余数为3的数
	for(ll i=0;i<n*2;i++){
		for(ll j=0;j<n*2;j++){
			if((i>>tot)%2)dp[i][j]=1;
		}
	}
}
void solve()
{
	scanf("%lld%lld%lld",&n,&sum,&ans);
	check(sum);
	check(ans);
	for(int i=0;i<n*2;i++){
		for(int j=0;j<n*2;j++){
			if(cnt==n*n) return ;
			if(!dp[i][j]) printf("%d %d\n",i,j ),cnt++;
		}
	}
}
Atcoder Choosing Points(数学分析好题)
标签:链接 sum 距离 ++ lld contest check https poi
原文地址:https://www.cnblogs.com/KingZhang/p/14837679.html