为什么式子推出来了才20分
查看原帖
为什么式子推出来了才20分
565698
czx2021楼主2022/10/29 15:38

大佬帮忙看一下

#include<bits/stdc++.h>
using namespace std;
bool f(int x){
	if((int)(sqrt(x))*(int)(sqrt(x))==x)
	  return true;
    else return false;
} 
int main()
{
    int k;
	cin>>k;
	while(k--){
		int n,e,d;
		cin>>n>>e>>d;
		int t=n-e*d+2,b=n;
		int tmp=sqrt(t*t-4*n);
	    if(!f(t*t-4*b)){
	    	cout<<"NO"<<endl;
	    	continue;
	    }	
	    if(abs(t-tmp)%2!=0){
	    	cout<<"NO"<<endl;
	    	continue;
	    }
	    else {
	    	int q=abs(t-tmp); 
	    	cout<<min((tmp+t)/2,q/2)<<" "<<max((tmp+t)/2,q/2)<<endl;
	    }
	} 
	return 0;
}
2022/10/29 15:38
加载中...