QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226767#5152. Circular Caramel CookieFyind#WA 0ms3908kbC++231.7kb2023-10-26 15:49:072023-10-26 15:49:08

Judging History

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

  • [2023-10-26 15:49:08]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3908kb
  • [2023-10-26 15:49:07]
  • 提交

answer

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

bool check(ll x, ll s, ll dx, ll dy) {
	// cout << dx << ' ' << dy << endl;
	ll cnt = 0;
	for (ll i = 1; (2 * i - dx) * (2 * i - dx) <= x; ++i) {
		ll l = 0, r = sqrt(x);
		ll res = x - (2 * i - dx) * (2 * i - dx);
		while (l <= r) {
			ll mid = (l + r) >> 1;
			if ((2 * mid + dy) * (2 * mid + dy) <= res)
				l = mid + 1;
			else 
				r = mid - 1;
		}
		// cout << l << ',' << i << ',' << x << endl;
		// cout << res << endl;
		cnt += ((l - 1) * 2 + dy) * (1 + !(dx && i == 1));//, cout << cnt << '!';
	}
	// cout << x << ':' << cnt << ',' << s << endl;
	return cnt < s;
}
int main() {
	ll s;
	cin >> s;
	ll ans;
	{
		ll ss = (s + 3) / 4 * 4;
		// cout << s << endl;
		ll l = 0, r = 20 * ss;
		while (l <= r) {
			ll mid = (l + r) / 2;
			if(check(mid, ss, 0, 0))
				l = mid + 1;
			else 
				r = mid - 1;
		}
		ans = l;
	}
	// {
	// 	ll l = 0, r = 20 * s;
	// 	while (l <= r) {
	// 		ll mid = (l + r) / 2;
	// 		if(check(mid, s, 1, 1))
	// 			l = mid + 1;
	// 		else 
	// 			r = mid - 1;
	// 	}
	// 	// cout << l << endl;
	// 	ans = min(ans, l);
	// }
	// {
	// 	ll l = 0, r = 20 * s;
	// 	while (l <= r) {
	// 		ll mid = (l + r) / 2;
	// 		if(check(mid, s, 1, 0))
	// 			l = mid + 1;
	// 		else 
	// 			r = mid - 1;
	// 	}
	// 	// cout << l << endl;
	// 	ans = min(ans, l);
	// }
	// cout << ans << endl;
	ans = (ans + 3) / 4;
	long double l = 0, r = ans;
	while (r - l > 1e-12) {
		long double mid = (l + r) / 2;
		if (mid * mid <= ans)
			l = mid;
		else 
			r = mid;
	}
	cout << fixed << setprecision(12) << l << '\n';
	// cout << sqrt(ans) << endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3812kb

input:

11

output:

2.236067977499

result:

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

Test #2:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

59

output:

5.000000000000

result:

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

Test #3:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

1

output:

1.414213562372

result:

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

Test #4:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

2

output:

1.414213562372

result:

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

Test #5:

score: 0
Accepted
time: 0ms
memory: 3848kb

input:

3

output:

1.414213562372

result:

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

Test #6:

score: -100
Wrong Answer
time: 0ms
memory: 3848kb

input:

4

output:

1.414213562372

result:

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