QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#226727 | #5152. Circular Caramel Cookie | Fyind# | WA | 0ms | 3936kb | C++23 | 736b | 2023-10-26 14:46:02 | 2023-10-26 14:46:03 |
Judging History
answer
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
bool check(ll x, ll s) {
ll cnt = 0;
for (ll i = 1; i * i <= x; ++i) {
ll l = 0, r = sqrt(x);
ll res = x - 1ll * i * i;
while (l <= r) {
ll mid = (l + r) >> 1;
if (mid * mid <= res)
l = mid + 1;
else
r = mid - 1;
}
cnt += l - 1;//, cout << cnt << ',';
}
// cout << x << ':' << cnt << ',' << s << endl;
return cnt < s;
}
int main() {
ll s;
cin >> s;
s = (s + 3) / 4;
// cout << s << endl;
ll l = 0, r = 3 * s;
while (l <= r) {
ll mid = (l + r) / 2;
if(check(mid, s))
l = mid + 1;
else
r = mid - 1;
}
// cout << l << endl;
cout << fixed << setprecision(10) << sqrt(l) << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3936kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
59
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
1
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
2
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3896kb
input:
3
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3880kb
input:
4
output:
1.4142135624
result:
wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'