QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#201314#5152. Circular Caramel Cookiesalvator_noster#WA 3ms3888kbC++141003b2023-10-05 13:41:002023-10-05 13:41:00

Judging History

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

  • [2023-10-05 13:41:00]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3888kb
  • [2023-10-05 13:41:00]
  • 提交

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 = 1e9, 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: 3ms
memory: 3876kb

input:

11

output:

2.2360679775

result:

ok found '2.2360680', expected '2.2360680', error '0.0000000'

Test #2:

score: 0
Accepted
time: 3ms
memory: 3860kb

input:

59

output:

5.0000000000

result:

ok found '5.0000000', expected '5.0000000', error '0.0000000'

Test #3:

score: 0
Accepted
time: 3ms
memory: 3808kb

input:

1

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #4:

score: 0
Accepted
time: 3ms
memory: 3868kb

input:

2

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #5:

score: 0
Accepted
time: 3ms
memory: 3888kb

input:

3

output:

1.4142135624

result:

ok found '1.4142136', expected '1.4142136', error '0.0000000'

Test #6:

score: -100
Wrong Answer
time: 3ms
memory: 3876kb

input:

4

output:

1.4142135624

result:

wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142136', error = '0.3675445'