Stacking Cylinders POJ - 2194 (判断顶端圆的位置)

传送门

题意:给出最低端一排桶的横坐标,最后得出最顶端桶的坐标

题解:一个一个桶分析,当加了一个桶以后,那么就可以看出顶端圆的变化,顶端圆横坐标的变化是增加了(x[i]+x[i+1])/2,纵坐标的变化是增加了sqrt(4-(x[i+1]-x[i])*(x[i+1]-x[i])/4)

Stacking Cylinders POJ - 2194 (判断顶端圆的位置)_第1张图片

附上代码:(这个代码有点强,在voj上排了个第一)


#include
#include
#include
#include

using namespace std;

const int maxn=15;

int n;
double x[maxn],X,Y;

int main()
{
    while(scanf("%d",&n)!=EOF&&n){
        for(int i=0;i

 

你可能感兴趣的:(Stacking Cylinders POJ - 2194 (判断顶端圆的位置))