1 solutions

  • 0
    @ 2023-12-3 20:53:31

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int k;
    int main()
    {
    	//freopen("decode.in","r",stdin);
    	//freopen("decode.out","w",stdout);
    	scanf("%d",&k);
    	for(int i=1;i<=k;i++)
    	{
    		long long n,d,e;
    		scanf("%lld %lld %lld",&n,&d,&e);
    		long long s=n-d*e+2;
    		long long r=(n-d*e+2)/2,l=1;
    		while(l<r)
    		{
    			int mid=(l+r)/2;
    			if(mid*(s-mid)>=n)
    			{
    				r=mid;
    			}
    			else
    			{
    				l=mid+1;
    			}
    		}
    		if(l*(s-l)==n)
    		{
    			printf("%lld %lld\n",l,(s-l));
    		}
    		else
    		{
    			printf("NO\n");
    		}
    		
    	}
    	
    	return 0;
    }
    
    • 1

    Information

    ID
    1185
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By