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