90,re,球救
查看原帖
90,re,球救
893428
qiaozhipeng123楼主2024/8/15 15:28
#include<bits/stdc++.h>
#define int long long
using namespace std;
int k;
int pq,ppqq,p,q;
int n,d,e;
signed main(){
	cin>>k;
	while(k--){
		cin>>n>>d>>e;
		pq=n-d*e+2;
		if(sqrt(pow(pq,2)-4*n)!=(double)(sqrt(pow(pq,2)-4*n))){
			cout<<"NO"<<endl;
			continue;
		}
		ppqq=sqrt(pq*pq-4*n);
		if((pq+ppqq)%2!=0){
			cout<<"NO"<<endl;
			continue;
		}
		p=(pq+ppqq)/2;
		q=pq-p;
		if(q*p==n&&e*d==(p-1)*(q-1)+1&&q>0&&p>0){
		cout<<min(q,p)<<" "<<max(p,q)<<endl;
	}
		else{
			cout<<"NO"<<endl;
		}
}
	return 0;
}
2024/8/15 15:28
加载中...