栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

poj 2850 Stacking Cylinders

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

poj 2850 Stacking Cylinders

#include<cstdio>#include<algorithm>#include<cmath>#include<iostream>#include<cstring>#define LL long long#define MaxN 100005 #define lson l,m,rt<<1#define rson m+1,r,rt<<1|1#define PI (acos(-1.0))struct Point {double x,y;};typedef Point Vector;Point a[500];Point b,c;Vector v1,v2;void updatax(int i){v1.x=(a[i+1].x-a[i].x)/2.0;v1.y=(a[i+1].y-a[i].y)/2.0;double L=sqrt(v1.x*v1.x+v1.y*v1.y);double ll=sqrt(4.0-L*L);v2.x=-v1.y/L*ll;v2.y=v1.x/L*ll;b.x=a[i].x+v1.x+v2.x;b.y=a[i].y+v1.y+v2.y;c.x=a[i].x+v1.x-v2.x;c.y=a[i].y+v1.y-v2.y;if(b.y>c.y){a[i].x=b.x;a[i].y=b.y;}else{a[i].x=c.x;a[i].y=c.y;}}int main(){int tt;scanf("%d",&tt);for(int t=1;t<=tt;t++){int n;scanf("%d",&n);for(int i=0;i<n;i++){scanf("%lf",&a[i].x);a[i].y=1.0;}for(int r=n-1;r>=0;r--)for(int i=0;i<r;i++){updatax(i);}printf("%d: ",t);printf("%.4lf %.4lfn",a[0].x,a[0].y);}}
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/371138.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号