QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#501173#5152. Circular Caramel CookieFoedere0WA 0ms3908kbC++231.9kb2024-08-02 15:18:292024-08-02 15:18:30

Judging History

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

  • [2024-08-02 15:18:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2024-08-02 15:18:29]
  • 提交

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)
        {
                long double annn = sqrt(0.5 * 0.5 + 0.5 * 0.5);
                annn=1.4142136;
                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;
}

详细

Test #1:

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

input:

11

output:

2.23606798

result:

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

Test #2:

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

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

input:

1

output:

1.41421

result:

wrong answer 1st numbers differ - expected: '1.4142136', found: '1.4142100', error = '0.0000025'