QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201259#5152. Circular Caramel Cookiesalvator_noster#WA 1ms3944kbC++20614b2023-10-05 13:25:202023-10-05 13:25:20

Judging History

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

  • [2023-10-05 13:25:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3944kb
  • [2023-10-05 13:25:20]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef double f64;

long long calc(f64 r) {
    long long res = 0;
    const f64 r2 = r * r;
    for (int l = 1; l < r; ) {
        int cnt = floor(sqrt(r2 - l * l));
        int nxt = floor(sqrt(r2 - cnt * cnt));
        res += 4ll * (nxt - l + 1) * cnt;
        l = nxt + 1;
    }
    return res;
}

int main() {
    int s;
    scanf("%d", &s);
    double l = 0, r = 1e9;
    while (r - l > 1e-7) {
        f64 mid = (l + r) / 2;
        if (calc(mid) < s) l = mid;
        else r = mid;
    }
    printf("%.10lf\n", l);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3856kb

input:

11

output:

2.2360679419

result:

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

Test #2:

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

input:

59

output:

4.9999999696

result:

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

Test #3:

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

input:

1

output:

1.4142135241

result:

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

Test #4:

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

input:

2

output:

1.4142135241

result:

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

Test #5:

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

input:

3

output:

1.4142135241

result:

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

Test #6:

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

input:

4

output:

1.4142135241

result:

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