CSES - Datatähti 2023 loppu - Results
Submission details
Task:Pinta-ala
Sender:cppbetter
Submission time:2023-01-21 13:56:33 +0200
Language:C++20
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.00 sdetails

Code

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

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

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;

        bool yes = false;

        // Find all possible multiples and check:
        for(int j = 1; j < std::ceil(std::sqrt(a)); j++)
        {
            if(a % j == 0)
                if( (a / j + 1) * (j + 1) == b - 1)
                {
                    yes = true;
                    break;
                }    
        }

        yesNo.push_back(yes);
    }

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

    // Flawed test...
}

Test details

Test 1

Verdict:

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

correct output
YES
YES
YES
NO
NO
...

user output
NO
NO
NO
NO
NO
...

Test 2

Verdict:

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

correct output
NO
NO
NO
NO
NO
...

user output
NO
NO
NO
NO
NO
...

Test 3

Verdict:

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

correct output
NO
NO
NO
YES
YES
...

user output
NO
NO
NO
NO
NO
...