求调,样例能过,20分
查看原帖
求调,样例能过,20分
1400677
xxb13968999687楼主2025/8/4 15:16
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll T,n,e,d;
int main(){
	ios::sync_with_stdio(false); cin.tie(0);
	cin>>T;
	while(T--){
		cin>>n>>e>>d;
		int m=n-e*d+2,sp=sqrt(m*m-4*n);
		if(sp<0){
			cout<<"NO\n";
			continue;
		}
		int p=(sp+m)/2,q=(m-sp)/2;
		if(p>q) swap(p,q);
		if(p&&q&&p*q==n&&(p-1)*(q-1)+1==e*d) cout<<p<<' '<<q<<'\n';
		else cout<<"NO\n";
	}
	return 0;
}
2025/8/4 15:16
加载中...