首页 > 其他 > 详细

sicily 1206 Stacking Cylinders

时间:2015-06-11 20:42:56      阅读:137      评论:0      收藏:0      [点我收藏+]

算是一道比较简单的数学题了~

 1 #include <bits/stdc++.h>
 2 
 3 using namespace std;
 4 
 5 double a[1005];
 6 
 7 int main()
 8 {
 9     int n, t;
10     scanf("%d", &t);
11     int k=1;
12     while(t--)
13     {
14         scanf("%d", &n);
15         for(int i=0; i<n; i++)
16             scanf("%lf", &a[i]);
17         sort(a, a+n);
18         double x = (a[0] + a[n-1]) / 2;
19         double y=1;
20         for(int i=0; i<n-1; i++)
21             y += sqrt(4 - pow((a[i+1]-a[i])/2, 2));
22         printf("%d: ", k++);
23         printf("%.4lf %.4lf\n", x, y);
24     }
25     
26     return 0;
27 }

 

sicily 1206 Stacking Cylinders

原文:http://www.cnblogs.com/dominjune/p/4569900.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!