QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#501195 | #5152. Circular Caramel Cookie | 1DemonS1 | WA | 0ms | 3936kb | C++20 | 1.1kb | 2024-08-02 15:34:50 | 2024-08-02 15:34:51 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2e5 + 9;
const int mod = 1e9 + 7;
const double eps = 1e-9;
#define inf 2e18
ll ans;
double d=sqrt(2);
bool check(double x)
{
ll res=0,now=0;
ll st = x/d;
res += st * st;
if(res * 4 >= ans) return false;
ll nx = st + 1, ny = st;
//find_now
while(nx <= x)
{
ll l = 0, r = sqrt(x * x - nx * nx) + 10;
while (l < r)
{
//cout<<l<<' '<<r<<'\n';
ll mid = (l + r)/2 + 1;
if (nx * nx + mid * mid <= x * x) l = mid;
else r = mid - 1;
}
now += l;
nx++;
}
now *= 2;
res += now;
res *= 4;
if(res >= ans) return false;
return true;
}
void solve()
{
cin>>ans;
double l=1, r=1e9 + 100, mid;
while(fabs(l-r)>=eps)
{
mid = (l+r)/2;
if(check(mid)) l = mid;
else r = mid;
}
printf("%.10lf",mid);
}
int main()
{
//ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int _ = 1; // cin>>_;
while (_--) solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3800kb
input:
11
output:
2.2360679772
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3872kb
input:
59
output:
4.9999999992
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1
output:
1.4142135630
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
2
output:
1.4142135630
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3856kb
input:
3
output:
1.4142135630
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3872kb
input:
4
output:
1.4142135630
result:
wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'