QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#226743 | #5152. Circular Caramel Cookie | Fyind# | WA | 1ms | 3664kb | C++23 | 1.5kb | 2023-10-26 15:16:12 | 2023-10-26 15:16:13 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool check(ll x, ll s, ll dx, ll dy) {
// cout << dx << ' ' << dy << endl;
ll cnt = 0;
for (ll i = 1; (2 * i - dx) * (2 * i - dx) <= x; ++i) {
ll l = 0, r = sqrt(x);
ll res = x - (2 * i - dx) * (2 * i - dx);
while (l <= r) {
ll mid = (l + r) >> 1;
if ((2 * mid + dy) * (2 * mid + dy) <= res)
l = mid + 1;
else
r = mid - 1;
}
// cout << l << ',' << i << ',' << x << endl;
// cout << res << endl;
cnt += ((l - 1) * 2 + dy) * (1 + !(dx && i == 1));//, cout << cnt << ',';
}
// cout << x << ':' << cnt << ',' << s << endl;
return cnt < s;
}
int main() {
ll s;
cin >> s;
if (s % 4 == 3 || s % 4 == 0) {
s = (s + 3) / 4 * 4;
// cout << s << endl;
ll l = 0, r = 5 * s;
while (l <= r) {
ll mid = (l + r) / 2;
if(check(mid, s, 0, 0))
l = mid + 1;
else
r = mid - 1;
}
cout << fixed << setprecision(10) << sqrt(l / 4.0) << '\n';
}
else if (s % 4 == 1) {
ll l = 0, r = 20 * s;
while (l <= r) {
ll mid = (l + r) / 2;
if(check(mid, s, 1, 1))
l = mid + 1;
else
r = mid - 1;
}
// cout << l << endl;
cout << fixed << setprecision(10) << sqrt(l / 4.0) << '\n';
}
else {
ll l = 0, r = 20 * s;
while (l <= r) {
ll mid = (l + r) / 2;
if(check(mid, s, 1, 0))
l = mid + 1;
else
r = mid - 1;
}
// cout << l << endl;
cout << fixed << setprecision(10) << sqrt(l / 4.0) << '\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3664kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
59
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3604kb
input:
1
output:
0.7071067812
result:
wrong answer 1st numbers differ - expected: '1.4142136', found: '0.7071068', error = '0.5000000'