HDU 5003 Osu!(数学题)

题目链接: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 ai will add 0.95^(i-1)*ai 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 a1, a2, ..., an separated by a single space, denoting the score of each song.

T<=20, n<=50, 1<=ai<=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 <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

double POW(int n)
{
    double s = 1;
    for(int i = 1; i <= n; i++)
    {
        s*=0.95;
    }
    return s;
}
int main()
{
    int n;
    int t;
    double a[57];
    while(~scanf("%d",&t))
    {
        while(t--)
        {
            scanf("%d",&n);
            for(int i = 1; i <= n; i++)
            {
                scanf("%lf",&a[i]);
            }
            sort(a+1,a+n+1);
            double ans = 0;
            int j = 0;
            for(int i = n; i >= 1; i--)
            {
                ans+=a[i]*POW(j++);
            }
            printf("%.10lf\n",ans);
        }
    }
    return 0;
}
时间: 2024-10-24 19:43:31

HDU 5003 Osu!(数学题)的相关文章

HDU 5003 Osu!(鞍山网络赛G题)

HDU 5003 Osu! 题目链接 就一签到题,排序之后for一遍计算出答案即可 代码: #include <cstdio> #include <cstring> #include <iostream> #include <string> #include <vector> #include <set> #include <map> #include <algorithm> #include <cmat

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

水.. #include <iostream> #include <cstdio> #include <string.h> #include <queue> #include <vector> #include <algorithm> #include <set> using namespace std; #define N 100 double a[N]; bool cmp(double x, double y){ re

HDU 5078 Osu!

题目链接:hdu 5078 Osu! 题面: Osu! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 1058    Accepted Submission(s): 550 Special Judge Problem Description Osu! is a very popular music game. Basically,

hdu 5587 Array 数学题

Array Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5587 Description Vicky is a magician who loves math. She has great power in copying and creating.One day she gets an array {1}. After that, every day she cop

hdu 5078 Osu! (2014 acm 亚洲区域赛鞍山 I)

题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5078 Osu! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 180    Accepted Submission(s): 114 Special Judge Problem Description Osu! is a very p

HDU 1018(数学题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 27548    Accepted Submission(s): 12526 Problem Description In many applications ve

HDU 6467 简单数学题 【递推公式 &amp;&amp; O(1)优化乘法】(广东工业大学第十四届程序设计竞赛)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6467 简单数学题 Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 308    Accepted Submission(s): 150 Problem Description 已知 F(n)=∑i=1n(i×∑j=inCij) 求 F(n) m

hdu 5078 Osu!(鞍山现场赛)

Osu! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 20    Accepted Submission(s): 15 Special Judge Problem Description Osu! is a very popular music game. Basically, it is a game about clicki

(水)hdu 5003

Osu! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 737    Accepted Submission(s): 371Special Judge Problem Description Osu! is a famous music game that attracts a lot of people. In osu!, there