QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226792#5152. Circular Caramel CookieFyind#WA 11ms3960kbC++231.0kb2023-10-26 16:24:412023-10-26 16:24:41

Judging History

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

  • [2023-10-26 16:24:41]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:3960kb
  • [2023-10-26 16:24:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _ <<" "<<
#define sz(x) ((int) (x).size())
typedef pair<int, int> pii;
typedef long long ll;
const int maxn = 1e5 + 5;
int n, m;
ll s; 

ll calc(ll r2, ll i) {
    ll ret = 0;
    int L = 0, R = sqrt(r2)+1;
    while (L < R) {
        ll M = (L+R)/2+1;
        if (M*M + i*i > r2) R = M-1;
        else L = M;
    }
    return L;
}

bool check(ll r2) {
    if (sqrt(r2) >= maxn) return true;
    ll cur = 0;
    for (ll i = 1;i*i <= r2; ++i) {
        cur += calc(r2, i); 
    }
    cur *= 4;
    return cur >= s;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    ll L = 1, R = LLONG_MAX/4;
    while (L < R) {
        ll M = (L+R)/2;
        if (check(M)) R = M;
        else L = M+1;
    }
    long double l = 0, r = L;
	while (r - l > 1e-12) {
		long double mid = (l + r) / 2;
		if (mid * mid <= L)
			l = mid;
		else 
			r = mid;
	}
    cout << fixed << setprecision(8) << l << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 7ms
memory: 3832kb

input:

11

output:

2.23606798

result:

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

Test #2:

score: 0
Accepted
time: 11ms
memory: 3900kb

input:

59

output:

5.00000000

result:

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

Test #3:

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

input:

1

output:

1.41421356

result:

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

Test #4:

score: 0
Accepted
time: 11ms
memory: 3900kb

input:

2

output:

1.41421356

result:

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

Test #5:

score: 0
Accepted
time: 11ms
memory: 3960kb

input:

3

output:

1.41421356

result:

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

Test #6:

score: -100
Wrong Answer
time: 11ms
memory: 3904kb

input:

4

output:

1.41421356

result:

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