QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#501170#5152. Circular Caramel CookieFoedere0WA 0ms3912kbC++231.9kb2024-08-02 15:14:212024-08-02 15:14:22

Judging History

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

  • [2024-08-02 15:14:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3912kb
  • [2024-08-02 15:14:21]
  • 提交

answer

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main(void)
{
        unsigned long long n;
        cin >> n;

        if (n == 0)
        {
                cout << 0 << endl;
                return 0;
        }
        else if (n == 1)
        {
                double annn = sqrt(0.5 * 0.5 + 0.5 * 0.5);
                cout << annn << endl;
                return 0;
        }


        unsigned long long k = 0;
        unsigned long long sum = 0;

        int num = 1;
        while(sum + k * 4 <= n)
        {
                sum += k * 4;
                sum += 4;
                num++;
                k = k + 2;
        }

        unsigned long long ksum = n - sum;
        ksum = ceil(ksum / 8.0);

        //cout << sum << endl;
        double r = sqrt(ksum * ksum + num * num);

//      cout << r << endl;


        unsigned long long k1 = 8;
        unsigned long long sum1 = 1;

        double num1 = 1;
        while(sum1 + k1 <= n)
        {
                sum1 += k1;
                num1++;
                k1 += 4;
        }

        double ksum1 = n - sum1;
        double bb = 0;
//      cout << ksum1 << endl;
        if (ksum1 <= 4 && ksum1 > 0)
        {
                bb = 0.5;
        }
        else if (ksum1 > 0)
        {
                bb = ceil((ksum1 - 4) / 8.0) + 0.5;
        }

        //cout << num1 << endl;
        double r1 = 0;
        if (bb != 0)
        {
                num1 -= 0.5;
                num1 += 1;
                r1 = sqrt(num1 * num1 + bb * bb);
        }
        else
        {
//              cout << num1 << endl;
                num1 -= 0.5;
//              cout << num1 << endl;
                r1 = sqrt(num1 * num1 * 2);
        }
//      cout << r1 << endl;

        cout << fixed << setprecision(8) << min(r, r1) << endl;
        return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3720kb

input:

11

output:

2.23606798

result:

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

Test #2:

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

input:

59

output:

5.00000000

result:

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

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3912kb

input:

1

output:

0.707107

result:

wrong answer 1st numbers differ - expected: '1.4142136', found: '0.7071070', error = '0.4999998'