Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- /**
- The program:
- You must find the sum of the mods of a list of numbers.
- Modular arithmetic refers to the remainder of the divide function. A mod B = the remainder of A/B.
- For example:
- 5 mod 2 = 1
- 15 mod 6 = 3
- **/
- using namespace std;
- int main()
- {
- int M, s;
- cin >> M; cin.ignore();
- int N;
- cin >> N; cin.ignore();
- for (int i = 0; i < N; i++) {
- int E;
- cin >> E; cin.ignore();
- s += E % M;
- } cout<< s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement