#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e7 + 2;
const int inf = 1e9;
vector<int> primes[M];
int idx[M], ans[N], koji[M], dp[M];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n, q;
cin >> n >> q;
for (int i = 0; i < n; i++) {
int x; cin >> x;
for (int j = x; j * 10 < M; j += x) primes[j].push_back(x);
}
cout << 1111 << endl;
return 0;
multiset<int> s;
for (int i = 0; i < n; i++) s.insert(0);
for (int i = 1; i <= q; i++) {
int x; cin >> x;
idx[x] = i;
}
for (int i = 1; i < M; i++) {
dp[i] = inf;
for (int j : primes[i]) {
s.erase(s.find(koji[j]));
}
if (!s.empty()) dp[i] = *(s.begin()) + 1;
ans[idx[i]] = dp[i];
for (int j : primes[i]) {
koji[j] = dp[i];
s.insert(koji[j]);
}
}
for (int i = 1; i <= q; i++) {
if (ans[i] >= inf) cout << "oo" << en;
else cout << ans[i] << en;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
120 ms |
240360 KB |
Output isn't correct |
2 |
Incorrect |
203 ms |
257940 KB |
Output isn't correct |
3 |
Incorrect |
146 ms |
254604 KB |
Output isn't correct |
4 |
Incorrect |
123 ms |
237380 KB |
Output isn't correct |
5 |
Incorrect |
132 ms |
243340 KB |
Output isn't correct |
6 |
Incorrect |
121 ms |
240336 KB |
Output isn't correct |
7 |
Incorrect |
142 ms |
254664 KB |
Output isn't correct |
8 |
Incorrect |
161 ms |
258668 KB |
Output isn't correct |
9 |
Incorrect |
181 ms |
260752 KB |
Output isn't correct |
10 |
Incorrect |
222 ms |
261732 KB |
Output isn't correct |
11 |
Incorrect |
189 ms |
257028 KB |
Output isn't correct |
12 |
Incorrect |
114 ms |
236744 KB |
Output isn't correct |
13 |
Runtime error |
187 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
189 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Incorrect |
173 ms |
257176 KB |
Output isn't correct |
16 |
Incorrect |
185 ms |
257760 KB |
Output isn't correct |
17 |
Incorrect |
146 ms |
243284 KB |
Output isn't correct |
18 |
Incorrect |
119 ms |
237392 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
143 ms |
240336 KB |
Output isn't correct |
2 |
Incorrect |
150 ms |
242264 KB |
Output isn't correct |
3 |
Runtime error |
184 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
174 ms |
248192 KB |
Output isn't correct |
5 |
Incorrect |
274 ms |
261532 KB |
Output isn't correct |
6 |
Incorrect |
160 ms |
253940 KB |
Output isn't correct |
7 |
Incorrect |
136 ms |
240420 KB |
Output isn't correct |
8 |
Incorrect |
161 ms |
246712 KB |
Output isn't correct |
9 |
Runtime error |
248 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Runtime error |
200 ms |
262144 KB |
Execution killed with signal 9 |
11 |
Runtime error |
182 ms |
262144 KB |
Execution killed with signal 9 |
12 |
Incorrect |
232 ms |
259132 KB |
Output isn't correct |
13 |
Incorrect |
156 ms |
242744 KB |
Output isn't correct |
14 |
Incorrect |
170 ms |
248112 KB |
Output isn't correct |
15 |
Runtime error |
208 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Incorrect |
149 ms |
242160 KB |
Output isn't correct |
17 |
Runtime error |
186 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
266 ms |
262144 KB |
Execution killed with signal 9 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
178 ms |
262144 KB |
Execution killed with signal 9 |
2 |
Runtime error |
183 ms |
262144 KB |
Execution killed with signal 9 |
3 |
Runtime error |
181 ms |
262144 KB |
Execution killed with signal 9 |
4 |
Incorrect |
251 ms |
260144 KB |
Output isn't correct |
5 |
Incorrect |
148 ms |
242380 KB |
Output isn't correct |
6 |
Runtime error |
248 ms |
262144 KB |
Execution killed with signal 9 |
7 |
Incorrect |
248 ms |
258636 KB |
Output isn't correct |
8 |
Runtime error |
177 ms |
262144 KB |
Execution killed with signal 9 |
9 |
Runtime error |
213 ms |
262144 KB |
Execution killed with signal 9 |
10 |
Incorrect |
262 ms |
258080 KB |
Output isn't correct |
11 |
Incorrect |
223 ms |
254516 KB |
Output isn't correct |
12 |
Runtime error |
283 ms |
262144 KB |
Execution killed with signal 9 |
13 |
Runtime error |
211 ms |
262144 KB |
Execution killed with signal 9 |
14 |
Runtime error |
180 ms |
262144 KB |
Execution killed with signal 9 |
15 |
Runtime error |
204 ms |
262144 KB |
Execution killed with signal 9 |
16 |
Runtime error |
178 ms |
262144 KB |
Execution killed with signal 9 |
17 |
Runtime error |
250 ms |
262144 KB |
Execution killed with signal 9 |
18 |
Runtime error |
184 ms |
262144 KB |
Execution killed with signal 9 |
19 |
Incorrect |
141 ms |
248312 KB |
Output isn't correct |
20 |
Runtime error |
188 ms |
262144 KB |
Execution killed with signal 9 |
21 |
Runtime error |
200 ms |
262144 KB |
Execution killed with signal 9 |
22 |
Runtime error |
181 ms |
262144 KB |
Execution killed with signal 9 |
23 |
Incorrect |
154 ms |
243848 KB |
Output isn't correct |
24 |
Incorrect |
132 ms |
240872 KB |
Output isn't correct |
25 |
Incorrect |
257 ms |
259400 KB |
Output isn't correct |
26 |
Incorrect |
241 ms |
260252 KB |
Output isn't correct |
27 |
Runtime error |
183 ms |
262144 KB |
Execution killed with signal 9 |
28 |
Incorrect |
153 ms |
246168 KB |
Output isn't correct |
29 |
Runtime error |
264 ms |
262144 KB |
Execution killed with signal 9 |
30 |
Runtime error |
218 ms |
262144 KB |
Execution killed with signal 9 |
31 |
Incorrect |
160 ms |
247372 KB |
Output isn't correct |
32 |
Incorrect |
178 ms |
250464 KB |
Output isn't correct |
33 |
Incorrect |
118 ms |
238484 KB |
Output isn't correct |
34 |
Incorrect |
253 ms |
258692 KB |
Output isn't correct |
35 |
Incorrect |
156 ms |
246988 KB |
Output isn't correct |
36 |
Runtime error |
183 ms |
262144 KB |
Execution killed with signal 9 |
37 |
Incorrect |
155 ms |
242320 KB |
Output isn't correct |
38 |
Runtime error |
260 ms |
262144 KB |
Execution killed with signal 9 |
39 |
Incorrect |
142 ms |
242712 KB |
Output isn't correct |
40 |
Incorrect |
282 ms |
261980 KB |
Output isn't correct |
41 |
Incorrect |
249 ms |
261092 KB |
Output isn't correct |
42 |
Runtime error |
205 ms |
262144 KB |
Execution killed with signal 9 |