6976 | 2023. 12. 23 17:51:21 | MagyarKendeSZLG | Sorozat generálás | cpp17 | Hibás válasz 28/50 | 21ms | 5948 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];
}
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
base | 28/50 | ||||||
1 | Elfogadva | 0/0 | 3ms | 1828 KiB | |||
2 | Hibás válasz | 0/0 | 18ms | 3484 KiB | |||
3 | Részben helyes | 1/2 | 3ms | 2100 KiB | |||
4 | Részben helyes | 1/2 | 3ms | 2396 KiB | |||
5 | Részben helyes | 1/2 | 3ms | 2608 KiB | |||
6 | Részben helyes | 1/2 | 3ms | 2548 KiB | |||
7 | Elfogadva | 2/2 | 3ms | 2840 KiB | |||
8 | Részben helyes | 2/4 | 4ms | 3156 KiB | |||
9 | Részben helyes | 2/4 | 6ms | 3372 KiB | |||
10 | Részben helyes | 2/4 | 9ms | 4108 KiB | |||
11 | Részben helyes | 2/4 | 8ms | 4064 KiB | |||
12 | Részben helyes | 2/4 | 12ms | 4448 KiB | |||
13 | Elfogadva | 4/4 | 16ms | 4920 KiB | |||
14 | Részben helyes | 2/4 | 21ms | 4924 KiB | |||
15 | Részben helyes | 2/4 | 19ms | 5248 KiB | |||
16 | Részben helyes | 2/4 | 19ms | 5528 KiB | |||
17 | Részben helyes | 2/4 | 19ms | 5948 KiB |