30分求大佬帮助
查看原帖
30分求大佬帮助
741732
small_Dongpo楼主2023/2/28 20:17

代码如下:

#include <iostream>
using namespace std;

int main()
{
    int k;
    cin >> k;
    for (int i = 1; i <= k; ++i)
    {
        long long n;
        int e, d;
        cin >> n >> e >> d;
        bool is_find = 0;
        for (int p = 1; p * p <= n; ++p)
        {
            if (n % p != 0) continue;
            if (e * d == (p - 1) * (n / p - 1) + 1)
            {
                is_find = 1;
                cout << p << " " << n / p;
                break;
            }
        }
        if (!is_find) cout << "No";
        cout << endl;
    }
    return 0;
}
2023/2/28 20:17
加载中...