QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#148950#5152. Circular Caramel CookieLaStataleBlue#WA 1ms3832kbC++201.1kb2023-08-23 20:50:152023-08-23 20:50:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-23 20:50:16]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3832kb
  • [2023-08-23 20:50:15]
  • 提交

answer

#pragma ide diagnostic ignored "misc-no-recursion"

#include "bits/stdc++.h"

using namespace std;
typedef long long ll;

#define TESTCASE 0

static constexpr int MOD = 998'244'353;
static constexpr int INF = 1e9;
static constexpr double EPS = 1e-10;

static ll count(double r) {
    ll x = r;
    ll res = 0;
    for (ll y = 1; y < r; y++) {
        while (x > 0 && (x * x + y * y) > r * r) {
            x--;
        }
        res += x;
    }
    return res * 4;
}

static void solve([[maybe_unused]] int tc) {
    ll S;
    cin >> S;

    double l = 0, r = 1e5;
    while ((r - l) > EPS) {
        double m = (l + r) / 2;
        if (count(m) < S) {
            l = m;
        } else {
            r = m;
        }
    }

    cout << setprecision(11) << r << endl;
}

int main() {
    ios::sync_with_stdio(false);

    if (const char *f = getenv("REDIRECT_STDOUT"); f) {
        freopen(f, "w", stdout);
    }

    int T = 1;
#if TESTCASE
    cin >> T;
#endif

    for (int t = 1; t <= T; t++) {
        solve(t);
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

input:

11

output:

2.2360679775

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 3616kb

input:

59

output:

5.0000000001

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3740kb

input:

1

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

2

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

3

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 3720kb

input:

4

output:

1.4142135624

result:

wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'