#P651. 分糖果

分糖果

題目描述

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?

輸入格式

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.

輸出格式

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.

Samples

2
7 3
1 2 3 4 5 6 7
5 10
7 7 7 7 7
Case #1: 1
Case #2: 5

原始資料

  • Zero1 題號:a651
  • Hydro 題號:Z0651
  • Locale:zh_TW
  • Display:open