QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#201308 | #5152. Circular Caramel Cookie | salvator_noster# | WA | 0ms | 3916kb | C++14 | 1001b | 2023-10-05 13:38:30 | 2023-10-05 13:38:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll mySqrt(ll num) {
ll le = 0.5 * sqrt(num), ri = ceil(2 * sqrt(num)), ans = -1;
while (le <= ri) {
ll mid = (le + ri) >> 1;
if (mid * mid <= num) {
ans = mid;
le = mid + 1;
} else {
ri = mid - 1;
}
}
return ans;
}
ll check(ll r2) {
ll res = 0;
for (ll le = 1; le * le <= r2;) {
ll cnt = mySqrt(r2 - le * le);
ll ri = mySqrt(r2 - cnt * cnt);
res += (ri - le + 1) * cnt * 4;
le = ri + 1;
}
return res;
}
int main(void) {
ll s;
scanf("%lld", &s);
ll le = 0, ri = s, ans = -1;
while (le <= ri) {
ll mid = (le + ri) >> 1;
if (check(mid) >= s) {
ans = mid;
ri = mid - 1;
} else {
le = mid + 1;
}
}
printf("%.10f\n", sqrt(ans));
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3916kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3876kb
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: 3808kb
input:
1
output:
-nan
result:
wrong output format Expected double, but "-nan" found