-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCandies.cpp
27 lines (25 loc) · 840 Bytes
/
Candies.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
Problem statement:
You have gathered N bags of candy and you want to distribute the candy amongst M kids. The i-th bag contains Ci 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?
*/
#include<iostream>
#include<vector>
using namespace std;
int main(){
int T;
cin>>T;
int x=1;
while(T--){
int bags,kids,tmp,sum=0;
cin>>bags>>kids;
for(int i=0;i<bags;i++){
cin>>tmp;
sum+=tmp;
}
cout<<"Case #"<<x++<<": "<<sum%kids<<endl;
}
return 0;
}