P8814 [CSP-J 2022] 解密(民间数据)全是RE和TLE

题目如下链接

https://www.luogu.com.cn/problem/P8814?contestId=90215#submit
我的代码放入洛谷后的结果如下

img

全是RE和TLE
我的做题思路是_暴力枚举_
先枚举出pi+qi的范围
然后在自定义函数中进行判断一系列条件
错误代码在下方


```c++
#include
#include
#include
using namespace std;
int jxpd(int c,int s1,int s2,int s3){
    int a,b;
    bool flag=false;
    for(int i=1;i2;i++){
        a=i;
        b=c-i;
        if(s1==a*b&&s2*s3==a*b-a-b+2){
            cout<" "<true;
        }
    }
    if(!flag){
        cout<<"NO"<int main(){
    
    int k;
    long long ed;
    cin>>k;
    for(int i=1;i<=k;i++){
        int x,y,z;
        cin>>x>>y>>z;
        ed=z*y;
        for(int j=1;jif(ed==x-j+2){
                jxpd(j,x,y,z);
//                cout<<"lhilu"<
            }
        }
    }
    
    return 0;
}

请问我这里该如何改呢?

试试这个

#include<bits/stdc++.h>
using namespace std;
typedef long long l;
int main(int argc, const char * argv[])
{
    l k;
    scanf("%lld", &k);
    for (l i = 1; i <= k; ++i)
    {
        l n,e,d;
        scanf("%lld%lld%lld", &n, &e, &d);
        l x=n-e*d+2;
        l y=sqrt((n-e*d+2)*(n-e*d+2)-4*n);
            l p=(x+y)/2;
            l q=x-p;
            if (p*q==n&&e*d==(p-1)*(q-1)+1&&p&&q)printf("%lld %lld\n", min(p,q),max(p,q));
            else printf("NO\n");
    }
    return 0;
}

我也不会呜呜