40pts求助!
查看原帖
40pts求助!
539947
LsmQwQ楼主2022/10/30 19:52
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=800, INF=0x3f3f3f3f;
ll k;
ll n,d,e;
int main(){
	ios::sync_with_stdio(0);
	cin>>k;
	for(ll i=1;i<=k;i++){
		cin>>n>>d>>e;
		ll p,q;
		ll m=n-e*d+2;
		ll l=m*m-4*n;
		ll f=sqrt(l);
		if(l<0||sqrt(l)*sqrt(l)!=l||(m+f)%2!=0||(m-f)%2!=0){
			printf("NO\n");
		}else{
			p=(m+f)/2;
			q=(m-f)/2;
			printf("%lld %lld\n",q,p);
		}
	}
	return 0;
}

实在不知道哪有问题,WA了6个点

2022/10/30 19:52
加载中...