1012 Stacking Cylinders
2013-12-29 12:43
323 查看
#include<iostream> #include<algorithm> #include<math.h> #include<stdio.h> using namespace std; int main() { int n; double arr[12]; while (cin>>n&&n!=0) { for (int i=0;i<n;i++) cin>>arr[i]; sort(arr,arr+n); double high=1.0; double xbefore=arr[0]; double xmid,yhigh; for (int i=1;i<n;i++) { xmid=(arr[0]+arr[i])/2.0; yhigh=sqrt(4.0-(xmid-xbefore)*(xmid-xbefore)); xbefore=xmid; high+=yhigh; } printf("%.4lf %.4lf\n",xbefore,high); } return 0; }
相关文章推荐
- SICILY 1934 移动小球
- 1920. Divide The Stones
- 1801. Reading books
- 1874. Three little pigs
- 1007[To and Fro]
- 1014[Specialized Four-Dig]
- 1024[MJ, Nowhere to Hide]
- 1036[Crypto Columns]
- 1147[谁拿了最多奖学金]
- 1157[The hardest problem]
- 1510[Mispelling]
- 1795[Table Tennis]
- 1798[Bob and Alice]
- 1815[Distance]
- Prime Palindromes
- Sicily 2013. Pay Back
- sicily 1011. Lenny's Lucky Lotto
- Sicily 1763. 传球游戏
- Sicily 1090. Highways
- Sicily 1001. Alphacode