QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#96633#5152. Circular Caramel CookieMostafa_MoharramWA 26ms3648kbC++14752b2023-04-14 22:10:432023-04-14 22:10:45

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-14 22:10:45]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3648kb
  • [2023-04-14 22:10:43]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ld = long double;

int s;
// 
// SSSS

bool inside(ld r, int x, int y) {
    return 1ll * x * x + 1ll * y * y <= r * r;
}
bool check(ld r) {
    int rm = 0;
    int x = r;
    int y = 1;
    while (x > 0) {
        while (x > 0 and not inside(r, x, y))
            --x;
        rm += x;
        ++y;
    }
    return 4 * rm > s;
}

signed main() {
    ios::sync_with_stdio(false); cout.tie(nullptr); cin.tie(nullptr);
    cin >> s;
    ld l = 0, r = 2 * sqrtl(s);
    for (int _ = 0; _ < 100; ++_) {
        ld m = (l + r) / 2;
        if (check(m))
            r = m;
        else l = m;
    }
    cout << fixed << setprecision(12) << l << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3552kb

input:

11

output:

2.236067977500

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

59

output:

5.000000000000

result:

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

Test #3:

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

input:

1

output:

1.414213562373

result:

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

Test #4:

score: 0
Accepted
time: 2ms
memory: 3480kb

input:

2

output:

1.414213562373

result:

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

Test #5:

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

input:

3

output:

1.414213562373

result:

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

Test #6:

score: 0
Accepted
time: 0ms
memory: 3648kb

input:

4

output:

2.236067977500

result:

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

Test #7:

score: -100
Wrong Answer
time: 26ms
memory: 3444kb

input:

1000000000

output:

55250.712248802730

result:

wrong answer 1st numbers differ - expected: '17841.8813190', found: '55250.7122488', error = '2.0966865'