Easy Marks

来源:互联网 发布:卸载程序找不到软件 编辑:程序博客网 时间:2024/06/06 15:46

The marks distribution in Amazing International University-Bangladesh is very strange. There are lots of quizzes in a semester. The average of all the quizzes is considered as the final mark. Unlike Tom Cruise, his friend Ananta Jalil thinks it is very easy to get specific average marks in this system. So Ananta made a bet with Tom that he can get exactly K average marks in a semester.

After N quizzes there is only one quiz left and Ananta wants to know the minimum number he needs in the last quiz to get exactly K average marks (Integer division) in this semester. Now as a friend of Ananta Jalil you got to help him to win this bet. It is guaranteed that Ananta will need some positive number in the last quiz to get Kfinal marks.

Input

Input starts with an integer T (≤ 100), denoting the number of test cases. Each of the test cases consists of two lines. First line contains two integers N (1≤N≤10)and K (1≤K≤100). The second line contains N integers ai (0≤ai≤100) describing the numbers Ananta already got from the previous Nquizzes.

Output

For each case print the case number and the minimum number Ananta needs in the last quiz to get exactly K average marks. It is guaranteed that the valid output of the input set will always be positive and ≤100.

Example

Input:

2

4 50

40 70 35 45

3 20

25 15 20Output:

Case 1: 60

Case 2: 20
啥也不说了,上代码:
#include<cstdio>using namespace std;int main(){    int n;    while(scanf("%d",&n)!=EOF)    {        int a,b,c,sum;        for(int i=1;i<=n;i++)        {            sum=0;            scanf("%d %d",&a,&b);            for(int j=0;j<a;j++)            {                scanf("%d",&c);                sum+=c;            }            int ans=b*(a+1)-sum;            printf("Case %d: %d\n",i,ans);        }    }}

0 0
原创粉丝点击