QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#120294#5152. Circular Caramel CookiePetroTarnavskyi#WA 4ms3768kbC++171.1kb2023-07-06 16:27:422023-07-06 16:27:46

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-06 16:27:46]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3768kb
  • [2023-07-06 16:27:42]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;
using ld = long double;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

LL f(int r2)
{
	LL ans = 0;
	LL x = 1;
	while (x * x < r2)
	{
		LL y = sqrt(r2 - x * x) - 47;
		while (y < 0 || (y + 1) * (y + 1) + x * x <= r2) y++;
		ans += 4 * y;
		x++;
	}
	return ans;
}

void solve()
{
	int s;
	cin >> s;
	int l = 0, r = 1e9;
	while (l + 1 < r)
	{
		int m = (l + r) / 2;
		if (s > f(m))
			l = m;
		else
			r = m;
	}
	cout << fixed << setprecision(10) << sqrt(r) << '\n';
	
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while (t--)
	{
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 3588kb

input:

11

output:

2.2360679775

result:

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

Test #2:

score: 0
Accepted
time: 4ms
memory: 3680kb

input:

59

output:

5.0000000000

result:

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

Test #3:

score: 0
Accepted
time: 4ms
memory: 3652kb

input:

1

output:

1.4142135624

result:

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

Test #4:

score: 0
Accepted
time: 4ms
memory: 3768kb

input:

2

output:

1.4142135624

result:

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

Test #5:

score: 0
Accepted
time: 4ms
memory: 3580kb

input:

3

output:

1.4142135624

result:

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

Test #6:

score: -100
Wrong Answer
time: 2ms
memory: 3584kb

input:

4

output:

1.4142135624

result:

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