Imaginary Date hdu 3569

Imaginary Date

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 125    Accepted Submission(s): 85

Problem Description
XMM met his ex-girlfriend on Double Seventh Festival Day. Though what happened between these two little kids was in the past, there did exist some strange and complicated feelings or something you can call it desire, which XMM cannot deny and tried as hard as he can to keep those things inside to ensure nobody else knows. But as his friends, just to be clear, it is so obvious to us.

So, today is a day. How could XMM possibly give up this wonderful chance? He once again asked XLZ out and then took her to a nice restaurant and prepared to give some delicious chocolate to XLZ to satisfy her which we think is useless.

There are n kinds of chocolate in the restaurant, XLZ likes them in varying degrees. To simplify this, every chocolate have a integer value vi(1 <= vi <= 1000 for all 1 <= i <= n <= 1000). This implies how much XLZ likes it. But since it has been such a long time that XMM Broke up with XLZ, XMM didn’t know it. So he’d like to randomly choose a chocolate every minute to give it to her. The total time XMM has is m minutes (1 <= m <= 1000).But there is another restriction: the kitchen is not so effective so after XMM buy a chocolate, it needs k (1 <= k <= n) minutes to make this kind of chocolate which means the next time XMM can order this is at least k minutes later.

Now we want to know the expect value XLZ gets on that special night.
 

 

Input
The first line is a single integer T indicating the number of cases that follow.
For each case, three integers n, m, k are give in the first line which is mentioned above.
The next line contains n integers which are the value of the n chocolates.
 

 

Output
For each case just output the result in a single line in the format of "Case x: d" in which x is the case number counted from one and d is the expect value that Xlz gets, rounded to 5 digits after the decimal point.
 

 

Sample Input
 
   
2 3 3 1 1 3 5 4 4 4 1 2 3 4
 

 

Sample Output
 
   
Case 1: 9.00000 Case 2: 10.00000
 

 

Author
totalfrank
 

 

Source
2010 ACM-ICPC Multi-University Training Contest(13)——Host by UESTC
 

 

Recommend
zhouzeyong
数学题,要不是网断了昨天比赛时候就能A了……555
#include #include #include using namespace std; #define N 1010 #define min(a,b)a>b?b:a int n; int main() { int T; scanf("%d",&T); int i,j,n,m,k,a[N],b; for(i=1;i<=T;i++) { scanf("%d%d%d",&n,&m,&k); double ans=0; double sum=0; for(j=1;j<=n;j++) { scanf("%d",&a[j]); sum+=a[j]; } if(k<=n) ans=sum*1.0*m/n; else { ans+=m/k*sum; if(m%k

你可能感兴趣的:(ACM)