求助
查看原帖
求助
247533
__cht楼主2022/11/8 16:20

官网爆0,民间70pts

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    //freopen("decode.in", "r", stdin);
    //freopen("decode.out", "w", stdout);
    long long int k;
    cin >> k;
    while(k --)
    {
        long long int n, e, d;
        cin >> n >> e >> d;
        long long int b = n - e * d + 2;
        if(b * b - 4 * n < 0)
        {
            cout << "NO" << endl;
            continue;
        }
        if(sqrt(b * b - 4 * n) * sqrt(b * b - 4 * n) != b * b - 4 * n)
        {
            cout << "NO" << endl;
            continue;
        }
        long long int tmp = sqrt(b * b - 4 * n);
        long long int q = (-b + tmp) / -2;
        long long int q2 = (-b - tmp) / -2;
        if(q <= 0 && q2 <= 0)
        {
            cout << "NO" << endl;
            continue;
        }
        if(int(n / q) * q != n || q <= 0 || q == 1)
        {
            if(int(n / q2) * q2 != n || q2 <= 0 || q2 == 1)
            {
                cout << "NO" << endl;
                continue;
            }
            cout << min(q2, n / q2) << ' ' << max(q2, n / q2) << endl;
        }
        else cout << min(q, n / q) << ' ' << max(q, n / q) << endl;
    }
    return 0;
}
2022/11/8 16:20
加载中...