hdu 5003 Osu! 水题 2014 ACM/ICPC Asia Regional Anshan Online

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

Problem Description
Osu! is a famous music game that attracts a lot of people. In osu!, there is a performance scoring system, which evaluates your performance. Each song you have played will have a score. And the system will sort all you scores in descending order. After that, the i-th song scored a i will add 0.95^(i-1)*a i to your total score.

Now you are given the task to write a calculator for this system.
 

Input
The first line contains an integer T, denoting the number of the test cases.

For each test case, the first line contains an integer n, denoting the number of songs you have played. The second line contains n integers a 1, a 2, ..., a n separated by a single space, denoting the score of each song.

T<=20, n<=50, 1<=a i<=500.
 

Output
For each test case, output one line for the answer.

Your answers will be considered correct if its absolute error is smaller than 1e-5.
 

Sample Input
  
  
1 2 530 478
 

Sample Output
  
  
984.1000000000
 

Source
2014 ACM/ICPC Asia Regional Anshan Online

代码:
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>

using namespace std;

#define min2(x, y)     min(x, y)
#define max2(x, y)     max(x, y)
#define min3(x, y, z)  min(x, min(y, z))
#define max3(x, y, z)  max3(x, max(y, z))
#define clr(x, y)      memset(x, y, sizeof(x))
#define fr(i,n)        for(int i = 1; i <= n; i++)
#define upfr(i,j,n)    for(int i = j; i <= n; i++)
#define dowfr(i,j,n)   for(int i = n; i >= j; i--)
#define scf(n)         scanf("%d", &n)
#define ptf(n)         printf("%d",n)
#define ptfs(s)        printf("%s",s)
#define ptln()         printf("\n")
#define srt(a,n)       sort(a,n)
#define LL long long
#define pi acos(-1.0)
#define inf 1 << 31-1
#define eps 0.00001
#define maxn 55

int arr[maxn];
int cmp(int a, int b)
{
    return a > b;
}
int main()
{
    //freopen("D:\\ACM Contest\\2014 ACM\\2014 ACMICPC Asia Regional Anshan Online\\in.txt","r",stdin);
    int t;
    scf(t);
    while(t--)
    {
        int n;
        scf(n);
        fr(i,n)
            scanf("%d ", &arr[i]);
        sort(arr+1, arr+1+n, cmp);
        double sum  = 0;
        fr(i,n)
           {
               double tmp = 1;
               fr(j,i-1)
               tmp *= 0.95;
               sum += tmp * arr[i];
           }
        printf("%.10lf\n", sum);
    }
    return 0;
}





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值