QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#219417 | #5152. Circular Caramel Cookie | gramolis# | WA | 0ms | 3912kb | C++17 | 1.6kb | 2023-10-19 14:30:33 | 2023-10-19 14:30:34 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ld EPSILON = 1e-8;
ll can_fit_x_squares(ld x, ld y, ld radius){
ld d = sqrt(x * x + y * y);
return d <= radius;
}
ll try_radius(ld radius){
ll i_radius = ll(radius);
// for each column find how many rows of waffle we get
// we calculate ans for (+, +) quarter
ll cur_squares = 0;
for(ll i=0;i<=i_radius+1;i++){
// find max height of stack
ll l = 0;
ll r = radius + 1;
while(r - l >= 10){
ll mid = (r + l) / 2;
if(can_fit_x_squares(i + 1, mid, radius)){
l = mid - 1;
} else {
r = mid + 1;
}
}
for(ll y=r;y>=l;y--){
if(can_fit_x_squares(i + 1, y, radius)){
cur_squares += y;
break;
}
}
}
return cur_squares * 4;
}
// g++ -std=c++17 main.cpp -o main && ./main
// g++-12 -std=c++17 -O2 -Wall -lm main.cpp -o main && ./main
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//ofstream cout ("output.txt");
//ifstream cin ("input.txt");
ll s;
cin >> s;
ld l = ld(0);
ld r = sqrt(ld(s)) * ld(5.0);
while(r - l >= EPSILON) {
ld mid = (l + r) / ld(2);
if(try_radius(mid) >= s){
r = mid;
} else {
l = mid;
}
}
cout << fixed << setprecision(9) << l << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3912kb
input:
11
output:
2.236067977
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
59
output:
4.999999991
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
1
output:
1.414213553
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3912kb
input:
2
output:
1.414213557
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
3
output:
1.414213557
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3720kb
input:
4
output:
1.414213553
result:
wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'