为何输出全是NO
查看原帖
为何输出全是NO
1314719
DerrickDong楼主2024/10/24 21:45

改对必关,只不过我这个蒟蒻还是求个悬关

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int q;
    cin>>q;
    while(q--)
    {
        int n,e,d;
        cin>>n>>d>>e;
        bool flag = false;
        for(int i = 1;i<=n;i++)
        {
            for(int j = 1;j<=n;j++)
            {
                if(i * j == n && e * d == (i-1) * (j-1) - 1)
                {
                    cout<<i<<" "<<j<<endl;
                    flag = true;
                }
            }
        }
        if(flag == false)
        {
            cout<<"NO"<<endl;
        }
    }
    return 0;
}
2024/10/24 21:45
加载中...