forked from mahmudahsan/203-ACM-Problems-Code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10489.cpp
More file actions
executable file
·37 lines (31 loc) · 760 Bytes
/
Copy path10489.cpp
File metadata and controls
executable file
·37 lines (31 loc) · 760 Bytes
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
28
29
30
31
32
33
34
35
36
37
/* Problem: Boxes of Chocolates UVa 10489
Programmer: Md. Mahmud Ahsan
Description: Modular Arithmetic
Compiled: Visual C++ 7.0
Date: 21-08-06
*/
#include <iostream>
#include <string>
using namespace std;
int main(){
//freopen("input.txt", "r", stdin);
long long test, friends, boxes, result, i, j;
long long temp, temp2, finalResult;
cin >> test;
while(test--){
cin >> friends >> boxes;
finalResult = 0;
for (i = 0; i < boxes; ++i){
cin >> temp;
result = 1;
for (j = 0; j < temp; ++j){
cin >> temp2;
result = (temp2 * result) % friends;
}
finalResult += result % friends;
finalResult = finalResult % friends;
}
cout << finalResult << endl;
}
return 0;
}