90pts 求助
查看原帖
90pts 求助
367652
Jerrlee✅楼主2022/10/29 15:11

RT

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int t;
	cin>>t;
	while(t--){
		int n,x,y,mid,cur,tmp,res;
		cin>>n>>x>>y;
		int m=n-x*y+2;
		int l=m/2,r=m/2;
		if(m&1) r++,mid=m/2+1;
		else mid=m/2;
		while(mid>=0){
			res=tmp;
			tmp=cur;
			cur=mid;
			if(mid&1) mid=mid/2+1;
			else mid=mid/2;
			if(res==1&&tmp==1&&cur==1&&mid==1){cout<<"NO\n";break;}
			if(l*r>n) l-=mid,r+=mid;
			else if(l*r<n) l+=mid,r-=mid;
			else{cout<<l<<" "<<r<<endl;break;}
		}
	}
}

freopen 被我删了。

2022/10/29 15:11
加载中...