60分
查看原帖
60分
1356485
wai_xing_sheng_wu楼主2024/10/20 10:10
#include<iostream>
#include<cmath>
using namespace std;
long long k,n,e,d,q,p;
int main()
{
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        bool o=false;
        cin>>n>>d>>e;
        int x=sqrt(n);
        if(x*x==n)
        {
            if((x-1)*(x-1)+1==e*d)
            {
                cout<<x<<' '<<x<<endl;
                continue;
            }
        }
        long long z=e*d;
        for(int j=1;j<=x;j++)
        {
            if(n%j==0)
            {
                p=j;
                q=n/j;

                if(z==(p-1)*(q-1)+1)
                {
                    o=true;
                    cout<<p<<' '<<q;
                    break;
                }
            }
        }
        if(false==o)
        {
            cout<<"NO";
        }
        cout<<endl;
    }
}


2024/10/20 10:10
加载中...