Submission #624493

# Submission time Handle Problem Language Result Execution time Memory
624493 2022-08-08T10:50:33 Z Do_you_copy Kotrljanje (COCI18_kotrljanje) C++17
140 / 140
457 ms 57368 KB
#include <bits/stdc++.h>
#define taskname "test"
#define fi first
#define se second
#define pb push_back
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ull = unsigned ll;
using ld = long double;
using pii = pair <int, int>;
using pil = pair <int, ll>;
using pli = pair <ll, int>;
using pll = pair <ll, ll>;
mt19937 Rand(chrono::steady_clock::now().time_since_epoch().count());

ll min(const ll &a, const ll &b){
    return (a < b) ? a : b;
}

ll max(const ll &a, const ll &b){
    return (a > b) ? a : b;
}

//const ll Mod = 1000000007;
//const ll Mod2 = 999999999989;
//only use when required
const int maxN = 5001 + 1;

int n;
int c, d, b, m;
map <ll, vector <ll>> cnt;

inline ll sumdigit(ll u){
    if (u < b) return u;
    return sumdigit(u / b) + u % b;
}

void Init(){
    cin >> c >> d >> b >> m;
    ll pivot;
    for (int i = 0; ; ++i){
        ll _ = i * (b - 1);
        ll tem = c * _ + d;
        ll sum = sumdigit(tem);
        cnt[sum].pb(_);
        if (cnt[sum].size() == m){
            pivot = sum;
            break;
        }
    }
    for (ll i: cnt[pivot]) cout << i << " ";
}

signed main(){
    if (fopen(taskname".inp", "r")){
        freopen(taskname".inp", "r", stdin);
        //freopen(taskname".out", "w", stdout);
    }
    faster;
    ll tt = 1;
    //cin >> tt;
    while (tt--){
        Init();
    }

    if (fopen("timeout.txt", "r")){
        ofstream testout("timeout.txt");
        testout << double(clock()) / CLOCKS_PER_SEC;
        cerr << "\nTime elapsed: " << double(clock()) / CLOCKS_PER_SEC << "ms\n";
    }
}

Compilation message

kotrljanje.cpp: In function 'void Init()':
kotrljanje.cpp:47:29: warning: comparison of integer expressions of different signedness: 'std::vector<long long int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |         if (cnt[sum].size() == m){
      |             ~~~~~~~~~~~~~~~~^~~~
kotrljanje.cpp: In function 'int main()':
kotrljanje.cpp:57:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 282 ms 57368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5304 KB Output is correct
2 Correct 24 ms 5576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5180 KB Output is correct
2 Correct 27 ms 5916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 6132 KB Output is correct
2 Correct 29 ms 5800 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 6072 KB Output is correct
2 Correct 54 ms 6600 KB Output is correct
3 Correct 36 ms 6132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 6424 KB Output is correct
2 Correct 30 ms 5876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 1236 KB Output is correct
2 Correct 170 ms 7024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 405 ms 14488 KB Output is correct
2 Correct 236 ms 16172 KB Output is correct
3 Correct 457 ms 16372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 49 ms 7540 KB Output is correct
2 Correct 220 ms 12276 KB Output is correct
3 Correct 35 ms 6760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 30 ms 5892 KB Output is correct
2 Correct 32 ms 5304 KB Output is correct