#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, q;
int p[100009];
int ans[10000001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> q;
for(int i = 0; i < n; ++i)
cin >> p[i];
reverse(p, p+n);
ans[0] = 0;
int lim = 1e7+1;
for(int i = 1; i < lim; ++i){
for(int j = 0; j <= n; ++j){
if(j == n){
lim = i;
break;
}
if(i%p[j] != 0){
ans[i] = 1+ans[i-i%p[j]];
break;
}
}
}
while(q--){
int x;
cin >> x;
if(x >= lim)
cout << "oo\n";
else
cout << ans[x] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
2 |
Incorrect |
103 ms |
39544 KB |
Output isn't correct |
3 |
Incorrect |
3 ms |
1408 KB |
Output isn't correct |
4 |
Incorrect |
89 ms |
39500 KB |
Output isn't correct |
5 |
Incorrect |
103 ms |
39416 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
7 |
Incorrect |
3 ms |
1408 KB |
Output isn't correct |
8 |
Incorrect |
9 ms |
3840 KB |
Output isn't correct |
9 |
Incorrect |
100 ms |
39424 KB |
Output isn't correct |
10 |
Incorrect |
99 ms |
39512 KB |
Output isn't correct |
11 |
Incorrect |
97 ms |
39416 KB |
Output isn't correct |
12 |
Correct |
91 ms |
39548 KB |
Output is correct |
13 |
Incorrect |
85 ms |
39416 KB |
Output isn't correct |
14 |
Incorrect |
89 ms |
39544 KB |
Output isn't correct |
15 |
Incorrect |
98 ms |
39544 KB |
Output isn't correct |
16 |
Incorrect |
95 ms |
39416 KB |
Output isn't correct |
17 |
Incorrect |
94 ms |
39544 KB |
Output isn't correct |
18 |
Incorrect |
91 ms |
39544 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
75 ms |
39544 KB |
Output isn't correct |
2 |
Correct |
79 ms |
40568 KB |
Output is correct |
3 |
Correct |
78 ms |
40312 KB |
Output is correct |
4 |
Incorrect |
81 ms |
39496 KB |
Output isn't correct |
5 |
Correct |
81 ms |
40056 KB |
Output is correct |
6 |
Incorrect |
81 ms |
39416 KB |
Output isn't correct |
7 |
Incorrect |
80 ms |
39672 KB |
Output isn't correct |
8 |
Incorrect |
87 ms |
39544 KB |
Output isn't correct |
9 |
Incorrect |
80 ms |
40188 KB |
Output isn't correct |
10 |
Correct |
78 ms |
40176 KB |
Output is correct |
11 |
Incorrect |
80 ms |
39928 KB |
Output isn't correct |
12 |
Incorrect |
81 ms |
39544 KB |
Output isn't correct |
13 |
Incorrect |
78 ms |
39448 KB |
Output isn't correct |
14 |
Incorrect |
81 ms |
39548 KB |
Output isn't correct |
15 |
Incorrect |
80 ms |
39928 KB |
Output isn't correct |
16 |
Correct |
82 ms |
40568 KB |
Output is correct |
17 |
Incorrect |
81 ms |
39672 KB |
Output isn't correct |
18 |
Incorrect |
80 ms |
40640 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
91 ms |
40440 KB |
Output isn't correct |
2 |
Incorrect |
87 ms |
40312 KB |
Output isn't correct |
3 |
Incorrect |
89 ms |
40568 KB |
Output isn't correct |
4 |
Incorrect |
107 ms |
40440 KB |
Output isn't correct |
5 |
Incorrect |
107 ms |
41592 KB |
Output isn't correct |
6 |
Incorrect |
117 ms |
40620 KB |
Output isn't correct |
7 |
Incorrect |
94 ms |
41080 KB |
Output isn't correct |
8 |
Incorrect |
93 ms |
40440 KB |
Output isn't correct |
9 |
Incorrect |
99 ms |
40444 KB |
Output isn't correct |
10 |
Incorrect |
84 ms |
39800 KB |
Output isn't correct |
11 |
Incorrect |
89 ms |
39800 KB |
Output isn't correct |
12 |
Incorrect |
96 ms |
39800 KB |
Output isn't correct |
13 |
Incorrect |
95 ms |
40776 KB |
Output isn't correct |
14 |
Incorrect |
118 ms |
40768 KB |
Output isn't correct |
15 |
Incorrect |
90 ms |
39800 KB |
Output isn't correct |
16 |
Incorrect |
87 ms |
39800 KB |
Output isn't correct |
17 |
Incorrect |
82 ms |
40056 KB |
Output isn't correct |
18 |
Incorrect |
88 ms |
40312 KB |
Output isn't correct |
19 |
Incorrect |
82 ms |
39800 KB |
Output isn't correct |
20 |
Incorrect |
91 ms |
40568 KB |
Output isn't correct |
21 |
Incorrect |
110 ms |
40824 KB |
Output isn't correct |
22 |
Incorrect |
112 ms |
41720 KB |
Output isn't correct |
23 |
Incorrect |
105 ms |
40952 KB |
Output isn't correct |
24 |
Incorrect |
109 ms |
40568 KB |
Output isn't correct |
25 |
Incorrect |
111 ms |
40568 KB |
Output isn't correct |
26 |
Incorrect |
108 ms |
40568 KB |
Output isn't correct |
27 |
Incorrect |
93 ms |
41248 KB |
Output isn't correct |
28 |
Incorrect |
96 ms |
40696 KB |
Output isn't correct |
29 |
Incorrect |
112 ms |
41592 KB |
Output isn't correct |
30 |
Incorrect |
111 ms |
41336 KB |
Output isn't correct |
31 |
Incorrect |
105 ms |
40440 KB |
Output isn't correct |
32 |
Incorrect |
110 ms |
40584 KB |
Output isn't correct |
33 |
Incorrect |
108 ms |
40436 KB |
Output isn't correct |
34 |
Incorrect |
94 ms |
41080 KB |
Output isn't correct |
35 |
Incorrect |
101 ms |
40696 KB |
Output isn't correct |
36 |
Incorrect |
114 ms |
41464 KB |
Output isn't correct |
37 |
Incorrect |
107 ms |
41592 KB |
Output isn't correct |
38 |
Incorrect |
112 ms |
40644 KB |
Output isn't correct |
39 |
Incorrect |
111 ms |
40568 KB |
Output isn't correct |
40 |
Incorrect |
117 ms |
40568 KB |
Output isn't correct |
41 |
Correct |
91 ms |
41080 KB |
Output is correct |
42 |
Incorrect |
101 ms |
40696 KB |
Output isn't correct |