70分求助
查看原帖
70分求助
347664
菲斯斯夫斯基楼主2022/11/5 15:01

rt。

#include<bits/stdc++.h>
using namespace std;
long long t,n,d,e;
int main()
{
//	freopen("decode.in","r",stdin);
//	freopen("decode.out","w",stdout);
	cin>>t;
	while(t--)
	{
		scanf("%lld%lld%lld",&n,&d,&e);
		long long m=n-e*d+2;
		if(m<0)
		{
			printf("NO\n");
			continue;
		}
		if(n+1==m)
		{
			printf("1 %lld\n",n);
			continue;
		}
		long long l=1,r=sqrt(n),mid;
		while(l+1<r)
		{
//			cout<<l<<' '<<r<<endl;
			mid=(l+r)/2;
			long double t=n*1.0/mid;
			if(t+mid>m)
				l=mid;
			else r=mid;
		}
		if(n%r||r+n/r!=m)printf("NO\n");
		else printf("%lld %lld\n",r,n/r);
	}
	return 0;
}
2022/11/5 15:01
加载中...