50分求助!!!
查看原帖
50分求助!!!
314607
keziang楼主2023/8/9 15:38

50分求助(用韦达定理做的)

#include<bits/stdc++.h>
using namespace std;
int main()
{	
	int k;
	cin>>k;
	long long n,d,e;
	for(int i=1;i<=k;i++)
	{
		cin>>n>>d>>e;
		long long s=d*e;
		long long b=s-2-n,c=n; 
	double x1=0,x2=0;
		x1=(b+sqrt(b*b-4*c))/2,	x2=(b-sqrt(b*b-4*c))/2;
		if(x1==int(x1) && x2==int(x2)) 	cout<<-x1<<" "<<-x2<<endl;
		else cout<<"NO"<<endl;
			}
	
	return 0;
 } 

2023/8/9 15:38
加载中...