• hdu5003 Osu!排序实现水题


    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.

     

    题意:给出若干分数,要求降序排列后总分每次加0.95^(i-1)*ai

    水题

     1 #include<stdio.h>
     2 #include<string.h>
     3 #include<algorithm>
     4 using namespace std;
     5 
     6 double c[55];
     7 int a[55];
     8 
     9 bool cmp(int a,int b){return a>b;}
    10 
    11 int main(){
    12     c[1]=1;
    13     for(int i=2;i<=50;++i)c[i]=c[i-1]*0.95;
    14     int T;
    15     scanf("%d",&T);
    16     while(T--){
    17         int n;
    18         double sum=0;
    19         scanf("%d",&n);
    20         for(int i=1;i<=n;++i){
    21             scanf("%d",&a[i]);
    22         }
    23         sort(a+1,a+n+1,cmp);
    24         for(int i=1;i<=n;++i){
    25             sum+=a[i]*c[i];
    26         }
    27         printf("%.10lf
    ",sum);
    28     }
    29     return 0;
    30 }
    View Code
  • 相关阅读:
    fedora 安装open office
    git rebase(转)
    javascript typeof
    正则表达式入门
    XML格式
    zz 通用线程:Awk 实例,第 3部分
    ELF BIN HEX
    i2c总线(iic总线/ I square C)
    grep
    把Nginx注册成Windows 系统服务(转载)
  • 原文地址:https://www.cnblogs.com/cenariusxz/p/6843658.html
Copyright © 2020-2023  润新知