• hdu 5003 模拟水题 (2014鞍山网赛G题)


    你的一系列得分 先降序排列 再按0.95^(i-1)*ai 这个公式计算你的每一个得分 最后求和

    Sample Input
    1
    2
    530 478
    Sample Output
    984.1000000000

     1 # include <iostream>
     2 # include <cstdio>
     3 # include <algorithm>
     4 # include <map>
     5 # include <cmath>
     6 # define LL long long
     7 using namespace std ;
     8 
     9 int a[110] ;
    10 
    11 bool cmp (int x , int y)
    12 {
    13     return x > y ;
    14 }
    15 
    16 int main ()
    17 {
    18     int T ;
    19     scanf("%d" , &T) ;
    20     while(T--)
    21     {
    22         int n ;
    23         scanf("%d" , &n) ;
    24         int i ;
    25         for (i = 1 ; i<=n ;i++)
    26             scanf("%d" , &a[i]) ;
    27         sort(a+1,a+1+n,cmp) ;
    28         double sum = 0 ;
    29         for (i = 1 ; i<=n ;i++)
    30         {
    31             sum+=(pow(0.95,i-1)*a[i]) ;
    32         }
    33         printf("%.10lf
    " , sum) ;
    34     }
    35 
    36     return 0 ;
    37 }
    View Code
  • 相关阅读:
    [转] Foobar2000 DSP音效外挂元件-Part4
    谷歌三件套
    Android 线刷小白教程
    nginx负载均衡
    HTTPS证书
    防火墙iptables
    LNMP架构部署
    tomcat部署
    shell编程
    HTTP协议
  • 原文地址:https://www.cnblogs.com/mengchunchen/p/4603741.html
Copyright © 2020-2023  润新知