hdoj-5003-osu!

Source: Internet
Author: User
Tags pow

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

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

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

For each test case, the first line contains a integer n, denoting the number of songs you have played. The second line contains n integers a1, a2, ..., a separated by a single space, and 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 would be considered correct if it absolute error is smaller than 1e-5.

Sample Input

1
2
530 478

Sample Output

984.1000000000

Test instructions: Sort, calculate 0.95^ (i-1) *ai
The puzzle: Direct violence

 #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];
    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; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.