Submission #372525

#TimeUsernameProblemLanguageResultExecution timeMemory
372525gustasonOnes (LMIO17_vienetai)C++14
81 / 100
1085 ms384 KiB
#include <iostream> #include <cstdlib> #include <vector> using namespace std; const int NOT_DIV = -1; int N, M, D; void print_and_exit(int data) { if (data == NOT_DIV) { cout << "NESIDALO\n"; } else { cout << data << '\n'; } exit(0); } void advance(int &rem, int &sum, int digit) { rem = rem * 10 + digit; sum += rem / D; rem %= D; } int main(int argc, char const *argv[]) { cin >> N >> M >> D; if (N % M != 0) { print_and_exit(NOT_DIV); } int groups = N / M, zeros = M - 1; if (D == 1) { print_and_exit(groups); } int sum = 0, rem = 1; vector <bool> saw_rem(10, false); for (int g = 2; g <= groups; g++) { for (int z = 0; z < zeros; z++) { advance(rem, sum, 0); } advance(rem, sum, 1); // if (rem == 0) { // print_and_exit((groups % g == 0) ? sum * (groups / g) : NOT_DIV); // } // else if (saw_rem[rem]) { // print_and_exit(NOT_DIV); // } // else { // saw_rem[rem] = true; // } } print_and_exit((rem == 0) ? sum : NOT_DIV); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...