Submission #77651

#TimeUsernameProblemLanguageResultExecution timeMemory
77651ccinvKotrljanje (COCI18_kotrljanje)C++14
140 / 140
1108 ms10680 KiB
#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 (stderr)

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 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...
#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...