#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<stack>
#include<map>
#define PI acos(-1.0)
#define in freopen("in.txt", "r", stdin)
#define out freopen("out.txt", "w", stdout)
#define kuaidian ios::sync_with_stdio(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int maxn = 1000 + 7, maxd = 1e5 + 7;
const ll mod = 1e9 + 7;
const int INF = 0x7f7f7f7f;
int n;
double m;
double a[maxn];
double b[maxn];
double max_(double a, double b) {
return a > b ? a : b;
}
int main() {
scanf("%d%lf", &n, &m);
m *= 2.0;
for(int i = 1; i <= n; ++i) {
scanf("%lf", &a[i]);
b[i] = m / 2.0;
for(int j = i-1; j >= 1; --j) {
if(a[i] - a[j] > m || a[j] - a[i] > m) continue;
else {
b[i] = max_(b[i], b[j] + sqrt( (m*m) - fabs(a[i]-a[j])*fabs(a[i]-a[j]) ));
}
}
}
for(int i = 1; i <= n; ++i) {
printf("%.10f ", b[i]);
}
return 0;
}
Good Bye 2017 C - New Year and Curling
最新推荐文章于 2018-07-18 16:44:41 发布