60pts #20TLE(玄关)
查看原帖
60pts #20TLE(玄关)
1303391
sizhenhualei楼主2024/9/7 17:25

https://www.luogu.com.cn/problem/P8814

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	int k;cin>>k;
	for(int i=1;i<=k;i++){
		int n,d,e;cin>>n>>d>>e;
		int go=e*d;int pd=1;
		for(int p=1;p*p<=n;p++){
			
			if(n%p==0) {
			
			int q=n/p;
			if((p-1)*(q-1)+1==go) {
				pd=0;
				cout<<p<<" "<<q;
				break;
			}
			if(((p+n)/2)*((p+n)/2)<=p) p=(p+n)/2;
			else if(((p+n/2)/2)*((p+n/2)/2)<=p) p=(p+n/2)/2;
			}
			
		}	if(pd) cout<<"NO";
		cout<<endl;
	}
	return 0;
}
2024/9/7 17:25
加载中...