Submission #77651

# Submission time Handle Problem Language Result Execution time Memory
77651 2018-09-29T10:04:14 Z ccinv Kotrljanje (COCI18_kotrljanje) C++14
140 / 140
1108 ms 10680 KB
#include <bits/stdc++.h>
using namespace std;

#define oo 0x3f3f3f3f
#define mp make_pair
#define fi first
#define se second
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define FO(i,a,b) for (int i=(a);i<=(b);++i)
#define FD(i,a,b) for (int i=(a);i>=(b);--i)
#define FE(i,G,x) for(int i=(G).h[x];~i;i=(G).v[i].nxt)
typedef long long LL;
typedef pair<int, int> PII;

template <class T> inline bool chkmin(T& x, T y) { return x > y ? x = y, true : false; }
template <class T> inline bool chkmax(T& x, T y) { return x < y ? x = y, true : false; }

inline LL read(void) {
    LL x, f = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (x = 0; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
    return x * f;
}

int c, d, b, m;
vector<int> A[50100];

int get(LL x) {
    int r = 0;
    while (x) r += x % b, x /= b;
    return r;
}

int main(void) {
    c = read(), d = read(), b = read(), m = read();
    FO(i, 1, 1e9){
        int pp = get(1ll * c * (b - 1) * i + d) / (b - 1);
        A[pp].push_back(i);
        if (A[pp].size() == m){
            for (auto x: A[pp]) printf("%lld ",x * (b - 1));
            return 0;
        }
    }
    return 0;
}

Compilation message

kotrljanje.cpp: In function 'int main()':
kotrljanje.cpp:39:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if (A[pp].size() == m){
             ~~~~~~~~~~~~~^~~~
kotrljanje.cpp:40:59: warning: format '%lld' expects argument of type 'long long int', but argument 2 has type 'int' [-Wformat=]
             for (auto x: A[pp]) printf("%lld ",x * (b - 1));
                                                ~~~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1528 KB Output is correct
2 Correct 82 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 6172 KB Output is correct
2 Correct 51 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 51 ms 6172 KB Output is correct
2 Correct 55 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6172 KB Output is correct
2 Correct 63 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 56 ms 6172 KB Output is correct
2 Correct 123 ms 6172 KB Output is correct
3 Correct 76 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 6172 KB Output is correct
2 Correct 59 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 6172 KB Output is correct
2 Correct 427 ms 6172 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 965 ms 9768 KB Output is correct
2 Correct 648 ms 10616 KB Output is correct
3 Correct 1108 ms 10680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 114 ms 10680 KB Output is correct
2 Correct 530 ms 10680 KB Output is correct
3 Correct 72 ms 10680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 64 ms 10680 KB Output is correct
2 Correct 59 ms 10680 KB Output is correct