QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501173 | #5152. Circular Caramel Cookie | Foedere0 | WA | 0ms | 3908kb | C++23 | 1.9kb | 2024-08-02 15:18:29 | 2024-08-02 15:18:30 |
Judging History
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'