Submission #20138685


Source Code Expand

Copy
#include<iostream>
#include<cmath>

using namespace std;

typedef long long ll;

double X, Y, R;

ll my_sqrt(ll x) {
	ll ok = 0, ng = 2 * 1e9;
	while (ng - ok > 1) {
		ll mid = (ok + ng) / 2;
		if (mid * mid <= x)
			ok = mid;
		else
			ng = mid;
	}
	return ok;
}

ll floor10000(ll x) {
	if (x > 0)
		return x / 10000 * 10000;
	else
		return (x - 9999) / 10000 * 10000;
}

ll ceil10000(ll x) {
	if (x > 0)
		return (x + 9999) / 10000 * 10000;
	else
		return x / 10000 * 10000;
}

int main() {
	cin >> X >> Y >> R;
	ll mX = round(X * 10000.0), mY = round(Y * 10000.0), mR = round(R * 10000.0);
	mX %= 10000, mY %= 10000;
	ll ans = 0;
	ll max_my = floor10000(mY + mR);
	ll min_my = ceil10000(mY - mR);

	for (ll y = max_my; y >= min_my; y -= 10000.0) {
		ll span = my_sqrt(mR * mR - (y - mY) * (y - mY));
		ll max_mx = floor10000(mX + span);
		ll min_mx = ceil10000(mX - span);
		ans += (max_mx - min_mx) / 10000.0 + 1;
	}
	cout << ans << endl;
	return 0;
}

Submission Info

Submission Time
Task D - Circle Lattice Points
User Sen
Language C++ (GCC 9.2.1)
Score 400
Code Size 1006 Byte
Status AC
Exec Time 32 ms
Memory 3772 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 46
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All extreme_00.txt, extreme_01.txt, extreme_02.txt, extreme_03.txt, handmade_00.txt, handmade_01.txt, handmade_02.txt, handmade_marginal_00.txt, handmade_marginal_01.txt, handmade_marginal_02.txt, handmade_marginal_03.txt, handmade_marginal_04.txt, handmade_marginal_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_integer_00.txt, random_integer_01.txt, random_integer_02.txt, random_integer_03.txt, random_integer_04.txt, random_integer_05.txt, random_integer_06.txt, random_integer_07.txt, random_integer_08.txt, random_integer_09.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
extreme_00.txt AC 30 ms 3568 KB
extreme_01.txt AC 26 ms 3640 KB
extreme_02.txt AC 23 ms 3752 KB
extreme_03.txt AC 24 ms 3772 KB
handmade_00.txt AC 2 ms 3604 KB
handmade_01.txt AC 3 ms 3616 KB
handmade_02.txt AC 2 ms 3620 KB
handmade_marginal_00.txt AC 31 ms 3604 KB
handmade_marginal_01.txt AC 26 ms 3632 KB
handmade_marginal_02.txt AC 32 ms 3712 KB
handmade_marginal_03.txt AC 27 ms 3608 KB
handmade_marginal_04.txt AC 23 ms 3616 KB
handmade_marginal_05.txt AC 21 ms 3712 KB
random_00.txt AC 24 ms 3564 KB
random_01.txt AC 6 ms 3600 KB
random_02.txt AC 25 ms 3564 KB
random_03.txt AC 17 ms 3564 KB
random_04.txt AC 23 ms 3620 KB
random_05.txt AC 4 ms 3668 KB
random_06.txt AC 20 ms 3592 KB
random_07.txt AC 14 ms 3604 KB
random_08.txt AC 14 ms 3592 KB
random_09.txt AC 28 ms 3620 KB
random_10.txt AC 31 ms 3600 KB
random_11.txt AC 15 ms 3616 KB
random_12.txt AC 14 ms 3592 KB
random_13.txt AC 27 ms 3544 KB
random_14.txt AC 22 ms 3568 KB
random_15.txt AC 12 ms 3568 KB
random_16.txt AC 13 ms 3636 KB
random_17.txt AC 21 ms 3548 KB
random_18.txt AC 18 ms 3620 KB
random_19.txt AC 5 ms 3600 KB
random_integer_00.txt AC 15 ms 3600 KB
random_integer_01.txt AC 10 ms 3712 KB
random_integer_02.txt AC 24 ms 3572 KB
random_integer_03.txt AC 19 ms 3604 KB
random_integer_04.txt AC 11 ms 3632 KB
random_integer_05.txt AC 5 ms 3588 KB
random_integer_06.txt AC 17 ms 3616 KB
random_integer_07.txt AC 14 ms 3568 KB
random_integer_08.txt AC 7 ms 3604 KB
random_integer_09.txt AC 27 ms 3664 KB
sample_01.txt AC 2 ms 3716 KB
sample_02.txt AC 3 ms 3620 KB
sample_03.txt AC 32 ms 3660 KB