69762023-12-23 17:51:21MagyarKendeSZLGSorozat generáláscpp17Wrong answer 28/5021ms5948 KiB
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>
#define speed cin.tie(0); ios::sync_with_stdio(0)

using namespace std;
using u32 = unsigned long long;

int main() {
    speed;

    u32 M, X, A, B, N, K;
    cin >> M >> X >> A >> B >> N >> K;
    vector<u32> row(N);
    unordered_map<u32, u32> vis;
    bool found = 0;

    for (int i = 0; i < N; i++) {
        row[i] = i ? row[i - 1] : X;

        row[i] *= A;
        row[i] += B;

        string s = to_string(row[i]);
        while (s.size() != 4 * M) s = "0" + s;

        row[i] = stoi(s.substr(M, 2 * M));

        if (!found) {
            if (vis[row[i]]) {
                found = 1;
                cout << i + 1 - vis[row[i]] << '\n';
            } else {
                vis[row[i]] = i + 1;
            }
        }
    }

    sort(row.begin(), row.end());
    cout << row[K];
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1828 KiB
2Wrong answer0/018ms3484 KiB
3Partially correct1/23ms2100 KiB
4Partially correct1/23ms2396 KiB
5Partially correct1/23ms2608 KiB
6Partially correct1/23ms2548 KiB
7Accepted2/23ms2840 KiB
8Partially correct2/44ms3156 KiB
9Partially correct2/46ms3372 KiB
10Partially correct2/49ms4108 KiB
11Partially correct2/48ms4064 KiB
12Partially correct2/412ms4448 KiB
13Accepted4/416ms4920 KiB
14Partially correct2/421ms4924 KiB
15Partially correct2/419ms5248 KiB
16Partially correct2/419ms5528 KiB
17Partially correct2/419ms5948 KiB