60分,超时求大佬助!
查看原帖
60分,超时求大佬助!
983305
hyx0826楼主2023/7/10 15:43
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,h;
	int q,s=0;
	long long n[1000000],d[100000],e[100000];
	cin>>k;
	for(int i=1;i<=k;i++)
	{
		cin>>n[i]>>d[i]>>e[i];
	}
	for(int i=1;i<=k;i++)
	{
		s=0;
		h=n[i]-e[i]*d[i]+2;
		for(int j=0;j<=h/2;j++)
		{
			q=h-j;
			if(n[i]==q*j) 
			{ 
			    s=1;
				cout<<j<<" "<<q<<endl;
				break;
			}
		}
		if (s==0) cout<<"NO"<<endl;
	}
    return 0;
}
2023/7/10 15:43
加载中...