满江红,求调,玄关
查看原帖
满江红,求调,玄关
1104834
lucky213楼主2024/5/20 18:47
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll k,n,e,d,i;
int f(ll n,ll e,ll d){
	bool is=0;
	ll p,q;
	for(p=0;p;p++){
		for(q=0;q;q++){
			if(p*q==n&&e*d==(p-1)*(q-1)+1){
				is=1;
				if(p<=q){
					cout<<p<<" "<<q<<endl;
					is=1;
					return 0;
				}
				else{
					cout<<q<<" "<<p<<endl;
					is=1;
					return 0;
				}
			}
		}
	}
	if(!is){
		cout<<"NO"<<endl;
		return 0;
	}
}
int main(){
	cin>>k;
	for(i=1;i<=k;i++){
		cin>>n>>e>>d;
		f(n,e,d);
	}
	return 0;
}
2024/5/20 18:47
加载中...