QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#140697 | #5152. Circular Caramel Cookie | Gamal74# | WA | 1ms | 3756kb | C++20 | 2.1kb | 2023-08-16 17:10:47 | 2023-08-16 17:10:50 |
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 * i;
ll x = sqrtl(cur);
if(x)x = x * 2 + 1;
else x = 1;
x --;
if(!i)ret += x;
else ret += x * 2;
}
else{
if(!i)break;
ld cur = r * r - i * i;
ll x = sqrtl(cur);
if(x)x = x * 2 + 1;
else x = 1;
x --;
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3756kb
input:
11
output:
2.2360679775
result:
ok found '2.2360680', expected '2.2360680', error '0.0000000'
Test #2:
score: 0
Accepted
time: 1ms
memory: 3656kb
input:
59
output:
5.0000000000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3732kb
input:
1
output:
1.0000000000
result:
wrong answer 1st numbers differ - expected: '1.4142136', found: '1.0000000', error = '0.2928932'