HDU

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5753

Sample Input
4
3 2 4 5
5
3 5 99 32 12
 

Sample Output
6.000000
52.833333

分析:???

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<math.h>
 4 #include<queue>
 5 #include<algorithm>
 6 #include<time.h>
 7 using namespace std;
 8 
 9 const int maxn = 2005;
10 const int N=120007;
11 
12 #define lson rt<<1///rt*2
13 #define rson rt<<1|1///rt*2+1
14 
15 int main()
16 {
17     int n,i;
18     int a[1200];
19 
20     while(scanf("%d", &n) != EOF)
21     {
22         int sum=0;
23         for(i=1;i<=n;i++)
24         scanf("%d", &a[i]);
25 
26         if(n==1)
27             printf("%lf
",1.0*a[1]);
28         else if(n==2)
29             printf("%lf
",1.0*(a[1]+a[2])/2);
30         else
31         {
32             for(i=2;i<n;i++)
33                 sum+=a[i];
34             int x=a[1]+a[n];
35 
36             printf("%lf
", 1.0*x/2+1.0*sum/3);
37         }
38     }
39     return 0;
40 }
原文地址:https://www.cnblogs.com/weiyuan/p/5708166.html