QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#501325 | #5152. Circular Caramel Cookie | Grunray | WA | 0ms | 3920kb | C++20 | 2.6kb | 2024-08-02 16:47:01 | 2024-08-02 16:47:01 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS
#define itn int
#define PII pair<int, int>
#define PLI pair<long long, int>
#define fep(i, a, b) for(int i = (a); i >= (b); --i)
#define rep(i, a, b) for(int i = (a); i <= (b); ++i)
#include<bits/stdc++.h>
#include<unordered_map>
using ll = long long;
using ldou = long double;
using unll = unsigned long long;
using namespace std;
inline int read() {
int x = 0, f = 1; char ch = getchar();
while (ch < '0' || ch>'9') { if (ch == '-') f = -1; ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - 48; ch = getchar(); }
return x * f;
}
ll gcd(ll a, ll b) { // 最大公约数
while (b ^= a ^= b ^= a %= b)
;
return a;
}
ll lcm(ll a, ll b) { // 最小公倍数
return a / gcd(a, b) * b;
}
ll qmi(ll m, ll k, ll p) { // 快速幂
//求 m^k mod p,时间复杂度 O(logk)。
//m为底数,k为幂
ll res = 1 % p, t = m;
while (k) {
if (k & 1) res = res * t % p;
t = t * t % p;
k >>= 1;
}
return res;
}
unll qmi(unll m, unll k, unll p) { //龟速乘
ll res = 0, t = m;
while (k) {
if (k & 1) res = (res + t) % p;
k >>= 1;
t = (t << 1) % p;
}
return res;
}
////////////////////////////////////////////////////////////////////////////////
ll n, m, k;
const int N = 1e4 + 50;
const int M = 2e5 + 50;
const ll INF = 1e9;
const ll MODE = ll(998244353);
const double Pi = 3.1415926;
const double eps = 1e-6;
const int dx[4] = { 1,-1, 0, 0 };
const int dy[4] = { 0, 0, 1,-1 };
//priority_queue<int> p;//这是一个大根堆q
//priority_queue<int, vector<int>, greater<int> >q;//这是一个小根堆q
//priority_queue<ll, vector<ll>, greater<ll> >pq; // 小根
ll s;
bool check(double mid) {
int cnt = 0;
int ans = 0;
for (int i = 1; i <= mid; i++) {
cnt = sqrt(mid * mid - i * i);
ans += cnt;
}
ans *= 4;
return ans >= s;
}
double bser(double l, double r) {
while (r - l > eps) {
double mid = (l + r) / 2;
if (check(mid))
r = mid;
else
l = mid;
//cout << l << ' ' << r << '\n';
}
return l;
}
void solve() {
cin >> s;
if (s == 1) {
cout << fixed << setprecision(10) << sqrt(2) << '\n';
return;
}
double l = 0, r = sqrt(s);
cout << fixed << setprecision(10) << (double)bser(l, r) << '\n';
}
signed main() {
std::ios::sync_with_stdio(false); std::cin.tie(0), std::cout.tie(0);
/*freopen("out.txt", "r", stdin);
freopen("wrt.txt", "w", stdout);*/
int TTT = 1; //cin >> TTT;
while (TTT--) {
solve();
}
/*while (cin >> n >> m) {
solve();
}*/
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3832kb
input:
11
output:
2.2360678352
result:
ok found '2.2360678', expected '2.2360680', error '0.0000001'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3888kb
input:
59
output:
4.9999993583
result:
ok found '4.9999994', expected '5.0000000', error '0.0000001'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
1
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3812kb
input:
2
output:
1.4142128880
result:
ok found '1.4142129', expected '1.4142136', error '0.0000005'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
3
output:
1.4142132009
result:
ok found '1.4142132', expected '1.4142136', error '0.0000003'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3740kb
input:
4
output:
1.4142131805
result:
wrong answer 1st numbers differ - expected: '2.2360680', found: '1.4142132', error = '0.3675446'