QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501198#5152. Circular Caramel Cookie1DemonS1WA 0ms3940kbC++201.1kb2024-08-02 15:37:032024-08-02 15:37:03

Judging History

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

  • [2024-08-02 15:37:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3940kb
  • [2024-08-02 15:37:03]
  • 提交

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: 3876kb

input:

11

output:

2.2360679772

result:

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

Test #2:

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

input:

59

output:

4.9999999992

result:

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

Test #3:

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

input:

1

output:

1.4142135630

result:

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

Test #4:

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

input:

2

output:

1.4142135630

result:

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

Test #5:

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

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: 3876kb

input:

4

output:

1.4142135630

result:

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