QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201308#5152. Circular Caramel Cookiesalvator_noster#WA 0ms3916kbC++141001b2023-10-05 13:38:302023-10-05 13:38:30

Judging History

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

  • [2023-10-05 13:38:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3916kb
  • [2023-10-05 13:38:30]
  • 提交

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