20分求助
查看原帖
20分求助
820286
Aronmy楼主2022/12/4 17:29

测试没问题

#include <iostream>
#include <math.h>
using namespace std;
int main(){
	int k;cin >> k;
	for(int f=0;f<k;++f){
		int n,d,e;
		cin>>n>>d>>e;
		int m=n-(e*d)+2;
		int delta=m*m-4*n;
		if (delta<0){
			cout << "NO" << endl;
			continue;
		}
		float x=sqrt(delta);
		int x1=sqrt(delta);
		if(x-x1!=0){
			cout<<"NO"<<endl;
			continue;
		}
		float p=(m-x)/2;float q=(m+x)/2;
		int p1=(m-x)/2;int q1=(m+x)/2;
		if(p-p1!=0||q-q1!=0){
			cout << "NO" << endl;
			continue;
		}
		cout<<p<<" "<<q<<endl;
	}
}
2022/12/4 17:29
加载中...