QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#201249 | #5152. Circular Caramel Cookie | salvator_noster# | WA | 0ms | 3956kb | C++20 | 619b | 2023-10-05 13:22:24 | 2023-10-05 13:22:26 |
Judging History
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'