欢迎光临散文网 会员登陆 & 注册

CSP-J2022解密

2022-12-05 18:31 作者:讽刺派数学家  | 我要投稿

#include<bits/stdc++.h>

using namespace std;

int main(){

    int k;

    scanf("%d",&k);

    for(int i=0;i<k;i++){

        long long n,e,d;

        scanf("%lld%lld%lld",&n,&e,&d);

        long long j=n+2-e*d;

        long long tt = j*j -4*n;

        if(tt<0)

{

            printf("NO\n");

            continue;

        }

        long long st=sqrt(tt);

        if(st*st != tt)

{

            printf("NO\n");

            continue;   

        }

        long long first = st + j;

        if(first%2 != 0)

{

            printf("NO\n");

            continue;

        }

        first/=2;

        if(n%first != 0)

{

            printf("NO\n");

            continue;

        }       

        long long two = n/first;

        if(first > two)

{

            long long tmp = first;

            first = two;

            two = tmp;

        }

        printf("%lld %lld\n",first,two);

    }

    return 0;

}


CSP-J2022解密的评论 (共 条)

分享到微博请遵守国家法律