CSES - Datatähti 2023 loppu - Results
Submission details
Task:Pinta-ala
Sender:cppbetter
Submission time:2023-01-21 14:25:50 +0200
Language:C++ (C++20)
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED100
Test results
testverdicttime
#1ACCEPTED0.00 sdetails
#2ACCEPTED0.00 sdetails
#3ACCEPTED0.00 sdetails

Code

// a+1 b+1 = a+b = B- 1 - A

#include <iostream>
#include <vector>
#include <tuple>
#include <cmath>

bool crosses(double c, double a)
{
    // (a+1) (b+1) = B
    // ab+a+b+1 = B
    // a+b= B-A-1
    // A/b=B- A- 1-b
    // A=-b^2+(B- A- 1)b
    // 0=-b^2+(B- A- 1)b-A
    // b = (-c+-sqrt(c^2-4*(-1)*(-A))))/(2*-1)

    double delta = c*c-4*(-1)*(-a);

    if(delta >= 0 && ( (-c + sqrt(delta)) / (-2) > 0 || (-c - sqrt(delta)) / (-2) > 0))
        return true;
    
    return false;
}

int main()
{
    int t;
    std::cin >> t;

    std::vector<bool> yesNo;

    for(int i = 0; i < t; i++)
    {
        int a, b;
        std::cin >> a >> b;

        yesNo.push_back(crosses(b - a - 1, a));
    }

    for(auto a : yesNo)
    {
        if(a)
            std::cout << "YES\n";
        else
            std::cout << "NO\n";
    }
}

Test details

Test 1

Verdict: ACCEPTED

input
1000
578049 731905
262997 434601
559974 650052
458543 101143
...

correct output
YES
YES
YES
NO
NO
...

user output
YES
YES
YES
NO
NO
...
Truncated

Test 2

Verdict: ACCEPTED

input
1000
10000 9500
10000 9501
10000 9502
10000 9503
...

correct output
NO
NO
NO
NO
NO
...

user output
NO
NO
NO
NO
NO
...
Truncated

Test 3

Verdict: ACCEPTED

input
961
1 1
1 2
1 3
1 4
...

correct output
NO
NO
NO
YES
YES
...

user output
NO
NO
NO
YES
YES
...
Truncated