QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#226766#5152. Circular Caramel CookieFyind#Compile Error//C++231.7kb2023-10-26 15:48:282023-10-26 15:48:28

Judging History

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

  • [2023-10-26 15:48:28]
  • 评测
  • [2023-10-26 15:48:28]
  • 提交

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 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(10) << l << '\n';
	cout << sqrt(ans) << endl;
}

Details

answer.code: In function ‘int main()’:
answer.code:39:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   39 |                 ans = l;
      |                 ^~~
      |                 abs
answer.code:66:9: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   66 |         ans = (ans + 3) / 4;
      |         ^~~
      |         abs