Why Wa on Subtask
查看原帖
Why Wa on Subtask
908942
zshs楼主2024/7/16 10:07
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int k;
ll n,e,d,p,q,x,y;
int main(){
	cin>>k;
	while(k--){
		cin>>n>>e>>d;
		x=n-e*d+2;
		y=n*n-2*n*e*d-4*e*d+e*e*d*d+4;
		if(y<0||sqrt(y)*sqrt(y)!=y){
			cout<<"NO\n";
			continue;
		}
		y=sqrt(y);p=y+x;
		if(p%2!=0){
			cout<<"NO\n";
			continue;
		} 
		p/=2;q=x-p;
		if(p>q)swap(p,q);
		cout<<p<<" "<<q<<"\n";
	}
	return 0;
}


2024/7/16 10:07
加载中...