As soon as Moca entered the university last year as a freshman, she was told that the competition is fierce and everyone was desperately trying to improve their grades. As a result, in the last academic term, Moca studied just as hard as she did in high school.
The college will award scholarships based on the average score of the previous academic term. Unfortunately, someone has the same average score as Moca because the average score is calculated rounding down to only 1 decimal places. For example, Ran's average score is 48/5≈9.6 and Moca's average score is 29/3≈9.6, but apparently Moca's average score is higher.
Can you help Moca calculate her average score rounding down to k decimal places?
Input
The first line contains two integers n,k (1≤n,k≤105) – the number of courses and the number of decimal places.
The second line contains n integers a1,a2,…,an(0≤ai≤100) – the score of each course.
Output
Print one real number in a line that denotes Moca's average score. Notice that your answer must contain k decimal places.
Examples
Inputcopy | Outputcopy |
---|---|
3 10 94 100 99 | 97.6666666666 |
#include<stdio.h>
int main()
{
int n,k,w=0,a,y;
scanf("%d%d",&n,&k);
int b=n;
while(n--)
{
scanf("%d",&a);
w+=a;
}
printf("%d.",w/b);//整数部分
while(k--)
{
int x=w%b;//小数部分
x*=10;
w=x;
x/=b;
printf("%d",x);
}
}