📄 2054.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 2054 on 2006-01-07 at 21:19:40 */
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int MAX = 16;
const double R = 1.0;
int main()
{
int n, i, j;
double x[MAX], y[MAX];
while(scanf("%d", &n) != EOF && n != 0) {
for(i = 0; i < n; i++) scanf("%lf", &x[i]), y[i] = R;
sort(x, x+n);
for(i = 1; i < n; i++) {
for(j = 0; j < n - i; j++) {
double l = sqrt((x[j]-x[j+1])*(x[j]-x[j+1])+(y[j]-y[j+1])*(y[j]-y[j+1]));
double d = sqrt(4*R*R-l*l/4);
double a = (x[j]+x[j+1])/2 - d*(y[j+1]-y[j])/l;
double b = (y[j]+y[j+1])/2 + d*(x[j+1]-x[j])/l;
x[j] = a, y[j] = b;
}
}
printf("%.4lf %.4lf\n", x[0], y[0]);
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -