#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = int(1e5) + 10;
int r, n;
double dp[maxn];
int usg[maxn];
int uc[maxn];
int f(double c) {
int j = 1;
for (int i=1; i<=n; ++i) {
dp[i] = 0;
double jc = double(j)/i + dp[i-j] - c;
while (j+1 <= i) {
double tmp = double(j+1)/i + dp[i-j-1] - c;
if (jc < tmp) {
jc = tmp;
++j;
} else break;
}
dp[i] = jc;
usg[i] = i-j;
uc[i] = uc[i-j] + 1;
}
return uc[n];
}
int main()
{
cin >> n >> r;
double cl = 0, cr = 10;
for (int i=0; i<50; ++i) {
double mid = (cl+cr)/2;
if (r < f(mid)) cl = mid;
else cr = mid;
}
f(cl);
static char out[256];
sprintf(out, "%.10f", dp[n]+r*cl);
cout << out << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
332 KB |
Output is correct |
2 |
Correct |
2 ms |
332 KB |
Output is correct |
3 |
Correct |
2 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1780 KB |
Output is correct |
3 |
Correct |
35 ms |
1612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1740 KB |
Output is correct |
2 |
Correct |
36 ms |
1740 KB |
Output is correct |
3 |
Correct |
37 ms |
1784 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
35 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1836 KB |
Output is correct |
3 |
Correct |
40 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1804 KB |
Output is correct |
3 |
Correct |
35 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1740 KB |
Output is correct |
3 |
Correct |
36 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1740 KB |
Output is correct |
3 |
Correct |
36 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1740 KB |
Output is correct |
2 |
Correct |
35 ms |
1728 KB |
Output is correct |
3 |
Correct |
34 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
36 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1740 KB |
Output is correct |
3 |
Correct |
34 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1800 KB |
Output is correct |
3 |
Correct |
38 ms |
1836 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1740 KB |
Output is correct |
2 |
Correct |
36 ms |
1772 KB |
Output is correct |
3 |
Correct |
37 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
1740 KB |
Output is correct |
2 |
Correct |
37 ms |
1836 KB |
Output is correct |
3 |
Correct |
38 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
1740 KB |
Output is correct |
2 |
Correct |
38 ms |
1740 KB |
Output is correct |
3 |
Correct |
37 ms |
1740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
1840 KB |
Output is correct |
2 |
Correct |
39 ms |
1740 KB |
Output is correct |
3 |
Correct |
41 ms |
1740 KB |
Output is correct |