QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#219453#5152. Circular Caramel Cookiegramolis#AC ✓74ms3920kbC++171.6kb2023-10-19 14:55:082023-10-19 14:55:09

Judging History

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

  • [2023-10-19 14:55:09]
  • 评测
  • 测评结果:AC
  • 用时:74ms
  • 内存:3920kb
  • [2023-10-19 14:55:08]
  • 提交

answer

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;

const ld EPSILON = 1e-10;

ll can_fit_x_squares(ld x, ld y, ld radius){
    ld d_squared = x * x + y * y;
    return d_squared <= radius * 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+5;i++){
        // find max height of stack
        ll l = 0;
        ll r = radius + 5;

        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;
    s++;

    ld l = ld(0);
    ld r = sqrt(ld(s)) * ld(15.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: 3816kb

input:

11

output:

2.236067977

result:

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

Test #2:

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

input:

59

output:

5.000000000

result:

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

Test #3:

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

input:

1

output:

1.414213562

result:

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

Test #4:

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

input:

2

output:

1.414213562

result:

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

Test #5:

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

input:

3

output:

1.414213562

result:

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

Test #6:

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

input:

4

output:

2.236067977

result:

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

Test #7:

score: 0
Accepted
time: 74ms
memory: 3772kb

input:

1000000000

output:

17841.881318964

result:

ok found '17841.8813190', expected '17841.8813190', error '0.0000000'

Test #8:

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

input:

16

output:

3.162277660

result:

ok found '3.1622777', expected '3.1622777', error '0.0000000'

Test #9:

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

input:

60

output:

5.099019514

result:

ok found '5.0990195', expected '5.0990195', error '0.0000000'

Test #10:

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

input:

276

output:

10.049875621

result:

ok found '10.0498756', expected '10.0498756', error '0.0000000'

Test #11:

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

input:

476

output:

13.038404810

result:

ok found '13.0384048', expected '13.0384048', error '0.0000000'

Test #12:

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

input:

1860

output:

25.019992006

result:

ok found '25.0199920', expected '25.0199920', error '0.0000000'

Test #13:

score: 0
Accepted
time: 3ms
memory: 3872kb

input:

2837456

output:

951.008412160

result:

ok found '951.0084122', expected '951.0084122', error '0.0000000'

Test #14:

score: 0
Accepted
time: 66ms
memory: 3868kb

input:

871234652

output:

16653.642724641

result:

ok found '16653.6427246', expected '16653.6427246', error '0.0000000'

Test #15:

score: 0
Accepted
time: 42ms
memory: 3676kb

input:

345230848

output:

10483.500274240

result:

ok found '10483.5002742', expected '10483.5002742', error '0.0000000'

Test #16:

score: 0
Accepted
time: 50ms
memory: 3880kb

input:

506145784

output:

12693.594368814

result:

ok found '12693.5943688', expected '12693.5943688', error '0.0000000'

Test #17:

score: 0
Accepted
time: 36ms
memory: 3920kb

input:

253745836

output:

8987.840063107

result:

ok found '8987.8400631', expected '8987.8400631', error '0.0000000'

Test #18:

score: 0
Accepted
time: 56ms
memory: 3912kb

input:

659345872

output:

14487.745200686

result:

ok found '14487.7452007', expected '14487.7452007', error '0.0000000'

Test #19:

score: 0
Accepted
time: 30ms
memory: 3872kb

input:

193830482

output:

7855.448300384

result:

ok found '7855.4483004', expected '7855.4483004', error '0.0000000'

Test #20:

score: 0
Accepted
time: 2ms
memory: 3828kb

input:

981273

output:

559.504244845

result:

ok found '559.5042448', expected '559.5042448', error '0.0000000'

Test #21:

score: 0
Accepted
time: 6ms
memory: 3812kb

input:

8732419

output:

1667.851312318

result:

ok found '1667.8513123', expected '1667.8513123', error '0.0000000'

Test #22:

score: 0
Accepted
time: 3ms
memory: 3856kb

input:

9812379

output:

1767.942306751

result:

ok found '1767.9423068', expected '1767.9423068', error '0.0000000'

Test #23:

score: 0
Accepted
time: 22ms
memory: 3836kb

input:

98273476

output:

5593.614663167

result:

ok found '5593.6146632', expected '5593.6146632', error '0.0000000'

Test #24:

score: 0
Accepted
time: 68ms
memory: 3832kb

input:

897972343

output:

16907.244512338

result:

ok found '16907.2445123', expected '16907.2445123', error '0.0000000'

Test #25:

score: 0
Accepted
time: 11ms
memory: 3824kb

input:

28736734

output:

3025.066114980

result:

ok found '3025.0661150', expected '3025.0661150', error '0.0000000'

Test #26:

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

input:

88234239

output:

5300.238862542

result:

ok found '5300.2388625', expected '5300.2388625', error '0.0000000'

Test #27:

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

input:

928379434

output:

17191.110289914

result:

ok found '17191.1102899', expected '17191.1102899', error '0.0000000'

Test #28:

score: 0
Accepted
time: 10ms
memory: 3872kb

input:

23765822

output:

2751.073245117

result:

ok found '2751.0732451', expected '2751.0732451', error '0.0000000'

Test #29:

score: 0
Accepted
time: 3ms
memory: 3820kb

input:

3427481

output:

1045.143530813

result:

ok found '1045.1435308', expected '1045.1435308', error '0.0000000'

Test #30:

score: 0
Accepted
time: 34ms
memory: 3676kb

input:

234987432

output:

8649.266327267

result:

ok found '8649.2663273', expected '8649.2663273', error '0.0000000'

Test #31:

score: 0
Accepted
time: 3ms
memory: 3808kb

input:

3242949

output:

1016.643988818

result:

ok found '1016.6439888', expected '1016.6439888', error '0.0000000'

Test #32:

score: 0
Accepted
time: 34ms
memory: 3872kb

input:

238423423

output:

8712.268877853

result:

ok found '8712.2688779', expected '8712.2688779', error '0.0000000'

Test #33:

score: 0
Accepted
time: 10ms
memory: 3916kb

input:

23784378

output:

2752.147706792

result:

ok found '2752.1477068', expected '2752.1477068', error '0.0000000'

Test #34:

score: 0
Accepted
time: 20ms
memory: 3820kb

input:

83246355

output:

5148.270486289

result:

ok found '5148.2704863', expected '5148.2704863', error '0.0000000'