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\n",sum);
28     }
29     return 0;
30 }
View Code

 

转载于:https://www.cnblogs.com/cenariusxz/p/6843658.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值