-
Notifications
You must be signed in to change notification settings - Fork 3
/
D.cpp
68 lines (61 loc) · 1.4 KB
/
D.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// LUOGU_RID: 160423195
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ll long long
#define lf long double
#define _mp make_pair
#define _pb push_back
#define _1 first
#define _2 second
#define inf 3423423423423423422ll
#define MAX_N 3422
using namespace std;
ll read(){ll x = 0;char c = 0, v = 0;do{c = getchar();if(c == '-')v = 1;} while(c < '0' || c > '9');do{x = (x << 3) + (x << 1) + c - '0';c = getchar();} while(c >= '0' && c <= '9');return v ? -x : x;}
char gtc(){char c = 0;while(c < 33)c = getchar();return c;}
int n, m;
lf dpl[MAX_N], dp[MAX_N];
void MAIN()
{
n = read();
m = read();
dp[0] = 0;
for(int i = 1; i <= m; i++)
dp[i] = inf;
for(int i = 1; i <= n; i++)
{
for(int j = 0; j <= m; j++)
dpl[j] = dp[j], dp[j] = inf;
for(int k = 1; k <= m / (n - i + 1); k++)
for(int j = k; j <= m; j++)
dp[j] = min(dp[j], dpl[j - k] + (j - k) / (lf)k);
}
lf ans = inf;
for(int i = 0; i <= m; i++)
ans = min(ans, dp[i]);
ans = 2 * ans + n;
printf("%.15Lf\n", ans);
}
void CLEAR()
{
;
}
void EXP()
{
;
}
int main()
{
EXP();
int T = 1;
while(T--)
MAIN(), CLEAR();
return 0;
}