1 solutions

  • 0
    @ 2024-12-5 18:17:46

    C++ :

    #include<iostream>
    #include<math.h>
    using namespace std;
    typedef long long ll;
    ll n,e,d,m,k,q,p;
    int main(){
        scanf("%lld",&k);
        for(int i=1;i<=k;i++){
            scanf("%lld%lld%lld",&n,&e,&d);
            m=n-e*d+2;
            ll x=sqrt(m*m-4*n);
            if(x*x!=m*m-4*n){
                printf("NO\n");
            }
            else{
                printf("%lld %lld\n",(m-x)/2,(m+x)/2);
            }
        }
    }
    
    • 1

    Information

    ID
    9131
    Time
    1000ms
    Memory
    512MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By