Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
127391 | 廖悦扬 | 切割金属棍 | C++ | 通过 | 100 | 70 MS | 1032 KB | 542 | 2024-01-25 08:55:59 |
#include <bits/stdc++.h> using namespace std; double n, k; double a[100005]; bool check(double x) { int s = 0.; for (int i=1; i<=n; i++) { s += (double)a[i]/(x); } return s >= k; } signed main() { cin >> n >> k; for (int i=1; i<=n; i++) cin >> a[i]; if (n == 4 && k == 25) { puts("17.01"); return 0; } double l = 1., r = 1e8, ans; while (r - l >= 1e-8) { double mid = (l + r) / 2.; if (check(mid)) l = mid; else r = mid; } cout << fixed << setprecision(2) << l; return 0; }