QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#201249#5152. Circular Caramel Cookiesalvator_noster#WA 0ms3956kbC++20619b2023-10-05 13:22:242023-10-05 13:22:26

Judging History

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

  • [2023-10-05 13:22:26]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3956kb
  • [2023-10-05 13:22:24]
  • 提交

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 = sqrt(s);
    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: 0ms
memory: 3956kb

input:

11

output:

2.2360679341

result:

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

Test #2:

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

input:

59

output:

4.9999999878

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3940kb

input:

1

output:

0.9999999404

result:

wrong answer 1st numbers differ - expected: '1.4142136', found: '0.9999999', error = '0.2928933'