QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#140980 | #5152. Circular Caramel Cookie | beshoyhany | WA | 1ms | 3840kb | C++14 | 2.2kb | 2023-08-17 02:57:31 | 2023-08-17 02:57:34 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define pp push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ld long double
#define PI acos(-1)
#define sin(a) sin((a)*PI/180)
#define cos(a) cos((a)*PI/180)
#define ones(x) __builtin_popcountll(x)
//#define int ll
using namespace std;
void Drakon() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef Clion
freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}
unsigned long long inf = 1e10;
const double EPS = 1e-6;
const int MOD = 1000000007, N = 200005, LOG = 25;
ll gcd(ll x, ll y) {
return y ? gcd(y, x % y) : x;
}
ll lcm(ll a, ll b) {
return (a * b) / __gcd(a, b);
}
ll mul(const ll &a, const ll &b) {
return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
}
ll add(const ll &a, const ll &b) {
return (a + b + 2 * MOD) % MOD;
}
ll pw(ll x, ll y) {
ll ret = 1;
while (y > 0) {
if (y % 2 == 0) {
x = mul(x, x);
y = y / 2;
} else {
ret = mul(ret, x);
y = y - 1;
}
}
return ret;
}
ll get(ld r) {
ll ret = 0;
for (ll i = 0; i <= r; ++i) {
if (i + 1 <= r) {
ld cur = r * r - (i + 1) * (i + 1);
ll tmp = sqrtl(cur);
ll x = 2 * tmp + 1;
if (!tmp)
x = 0;
if (!i)ret += x;
else ret += x * 2;
}
else {
if (!i)break;
ld cur = r * r - i * i;
ll tmp = sqrtl(cur);
ll x = 2 * tmp + 1;
if (!tmp)
x = 0;
ret += x;
}
}
return ret;
}
void solve() {
int s;
cin >> s;
ld l = 1, r = 1e5, ans;
for (int i = 0; i < 100; ++i) {
ld mid = (l + r) / 2;
if (get(mid) > s) {
ans = mid;
r = mid;
} else {
l = mid;
}
}
cout << fixed << setprecision(10) << ans;
}
signed main() {
Drakon();
int t = 1;
//cin >> t;
while (t--) {
solve();
}
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 3732kb
input:
59
output:
5.0990195136
result:
wrong answer 1st numbers differ - expected: '5.0000000', found: '5.0990195', error = '0.0198039'