Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <iterator>
- #include <unordered_map>
- #include <functional>
- #include <unordered_set>
- #include <string>
- #include <set>
- #include <utility>
- #include <queue>
- int main() {
- int N, sum = 0;
- std::string number;
- std::cin >> N;
- std::cin >> number;
- if (N == 1) {
- std::cout << 0;
- } else {
- std::vector<int> r;
- r.resize(number.size() - 1);
- int r1 = 1;
- for (int i = 0; i < r.size(); i++) {
- r[i] = r1 * 10 % N;
- r1 = r[i];
- }
- int j = 1;
- long long summ = 0;
- summ += (number[number.size() - j]) - '0';
- j++;
- for (int i = 0; i < r.size(); i++) {
- summ += ((number[number.size() - j]) - '0') * r[i];
- j++;
- }
- std::cout << summ % N;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement