Submission #141176

# Submission time Handle Problem Language Result Execution time Memory
141176 2019-08-07T05:40:46 Z mariusnicoli Kotrljanje (COCI18_kotrljanje) C++14
28 / 140
2000 ms 3176 KB
#include <iostream>
#include <vector>
#include <map>

using namespace std;
map<long long, int> mp;
long long c, d, b, m, p, i, n, suma, sol;

int main () {

    cin>>c>>d>>b>>m;
    p = 1;
    while (p <= d)
        p*=b;
    for (i=1;;i++) {
        n = 1LL*c*i*p+d;
        suma = 0;
        while (n) {
            suma += n%b;
            n/=b;
        }
        if (mp.find(suma) == mp.end())
            mp[suma] = 1;
        else
            mp[suma] ++;

        if (mp[suma] == m) {
            sol = suma;
            break;
        }
        ///}
    }

    for (i=1;m;i++) {
        n = 1LL*c*i*p+d;
        suma = 0;
        while (n) {
            suma += n%b;
            n/=b;
        }
        if (suma == sol) {
            cout<<i*p<<" ";
            m--;
        }
        ///}
    }


}
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2023 ms 592 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2028 ms 472 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 752 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2037 ms 776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2012 ms 660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 112 ms 352 KB Output is correct
2 Correct 1244 ms 1544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2019 ms 1520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1342 ms 2668 KB Output is correct
2 Correct 1457 ms 3176 KB Output is correct
3 Correct 1835 ms 3084 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2005 ms 484 KB Time limit exceeded
2 Halted 0 ms 0 KB -