a651: 分糖果
Tags :
Accepted rate : 21人/26人 ( 81% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-03-21 10:56

Content

You have gathered NN bags of candy and you want to distribute the candy amongst MM kids. The ii-th bag contains CiCi pieces of candy. You want to make sure that every kid get the same amount of candy and that the number of pieces of candy they receive is the greatest possible. You can open each bag and mix all pieces of candy before distributing them to the kids.

How many pieces of candy will remain after you share the candy amongst kids, based on the rules described above?

Input

The first line of the input gives the number of test cases, TT. TT test cases follow.

Each test case consists of two lines. The first line of each test case contains two integers: integer NN, the number of candy bags, and MM, the number of kids.

The next line contains NN non-negative integers C1,C2,…,CNC1,C2,…,CN representing array CC, where the ii-th integer represents the number of candies in the ii-th bag.

Output

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 11) and y is the number of candies that will remain if you divide candies between kids according to the rules described above.

Sample Input #1
2
7 3
1 2 3 4 5 6 7
5 10
7 7 7 7 7
Sample Output #1
Case #1: 1
Case #2: 5
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (50%): 1.0s , <1K
公開 測資點#1 (50%): 1.0s , <50M
Hint :
Tags:
出處:
[管理者:
ricky (電腦黃)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」