CSES - Datatähti 2023 loppu - Results
Submission details
Task:Pinta-ala
Sender:andreibe
Submission time:2023-01-21 13:42:00 +0200
Language:C++ (C++11)
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#1ACCEPTED0.01 sdetails
#20.01 sdetails
#30.01 sdetails

Code

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define REDIR ifstream f("input.txt"); cin.rdbuf(f.rdbuf());
int n,t;
int sums[4];

bool ok(double leveys, int a, int b) {
    double korkeus = a / leveys;
    if ((korkeus+1) * (leveys+1) > b) return true;
    return false;
}
int main() {
    //REDIR;
    cin >> t;
    while (t--) {
        double a,b; cin >> a >> b;


        double z = 0;
        for (double k = 1 << 18; k>0.0000001; k/=2) {
            while (!ok(z+k, a, b)) z += k;
        }
        if (z == 0) {
            cout << "NO\n";
            continue;
        }
        double sum = ((a/z+1) * (z+1));
        bool onsamat = (abs(sum - b) < 0.001);
        //cout << (z+1) << " " << (a/z+1) << endl;
        //cout << (z+1) * (a/z+1) << " " << b<< endl;
        //cout << "SUM: " << sum << " " << b << " " << onsamat<< endl;
        if (onsamat) cout << "YES\n";
        else 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:

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:

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