Submission #36502

# Submission time Handle Problem Language Result Execution time Memory
36502 2017-12-10T03:22:46 Z cheater2k Brunhilda’s Birthday (BOI13_brunhilda) C++14
100 / 100
499 ms 80140 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX = 10000000;
const int inf = 1e9 + 10;

int nprime, nquery;
int maxdiv[MAX + 5];
int dp[MAX + 5];

int main() {
	scanf("%d %d", &nprime, &nquery);
	for (int i = 1; i <= MAX; ++i) dp[i] = inf;
	for (int i = 1; i <= nprime; ++i) {
		int p; scanf("%d", &p);
		for (int j = 0; j <= MAX; j += p) maxdiv[j] = p;
	}
	
	int cur = 0;
	for (int i = 1; i <= MAX; ++i) {
		while(cur < i) {
			if (!maxdiv[cur] || cur + maxdiv[cur] <= i) ++cur;
			else break;
		}
		if (cur == i) continue;
		dp[i] = min(dp[i], dp[cur] + 1);
	}

	while(nquery--) {
		int n; scanf("%d", &n);
		if (dp[n] != inf) printf("%d\n", dp[n]);
		else printf("oo\n");
	}
}

Compilation message

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:34: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &nprime, &nquery);
                                  ^
brunhilda.cpp:15:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int p; scanf("%d", &p);
                         ^
brunhilda.cpp:30:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   int n; scanf("%d", &n);
                         ^
# Verdict Execution time Memory Grader output
1 Correct 79 ms 80140 KB Output is correct
2 Correct 116 ms 80140 KB Output is correct
3 Correct 106 ms 80140 KB Output is correct
4 Correct 66 ms 80140 KB Output is correct
5 Correct 126 ms 80140 KB Output is correct
6 Correct 103 ms 80140 KB Output is correct
7 Correct 106 ms 80140 KB Output is correct
8 Correct 109 ms 80140 KB Output is correct
9 Correct 136 ms 80140 KB Output is correct
10 Correct 179 ms 80140 KB Output is correct
11 Correct 176 ms 80140 KB Output is correct
12 Correct 63 ms 80140 KB Output is correct
13 Correct 319 ms 80140 KB Output is correct
14 Correct 323 ms 80140 KB Output is correct
15 Correct 133 ms 80140 KB Output is correct
16 Correct 129 ms 80140 KB Output is correct
17 Correct 139 ms 80140 KB Output is correct
18 Correct 86 ms 80140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 113 ms 80140 KB Output is correct
2 Correct 136 ms 80140 KB Output is correct
3 Correct 416 ms 80140 KB Output is correct
4 Correct 176 ms 80140 KB Output is correct
5 Correct 293 ms 80140 KB Output is correct
6 Correct 93 ms 80140 KB Output is correct
7 Correct 103 ms 80140 KB Output is correct
8 Correct 166 ms 80140 KB Output is correct
9 Correct 353 ms 80140 KB Output is correct
10 Correct 443 ms 80140 KB Output is correct
11 Correct 419 ms 80140 KB Output is correct
12 Correct 219 ms 80140 KB Output is correct
13 Correct 89 ms 80140 KB Output is correct
14 Correct 166 ms 80140 KB Output is correct
15 Correct 356 ms 80140 KB Output is correct
16 Correct 133 ms 80140 KB Output is correct
17 Correct 349 ms 80140 KB Output is correct
18 Correct 346 ms 80140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 369 ms 80140 KB Output is correct
2 Correct 449 ms 80140 KB Output is correct
3 Correct 483 ms 80140 KB Output is correct
4 Correct 283 ms 80140 KB Output is correct
5 Correct 209 ms 80140 KB Output is correct
6 Correct 436 ms 80140 KB Output is correct
7 Correct 373 ms 80140 KB Output is correct
8 Correct 373 ms 80140 KB Output is correct
9 Correct 369 ms 80140 KB Output is correct
10 Correct 319 ms 80140 KB Output is correct
11 Correct 283 ms 80140 KB Output is correct
12 Correct 353 ms 80140 KB Output is correct
13 Correct 446 ms 80140 KB Output is correct
14 Correct 226 ms 80140 KB Output is correct
15 Correct 343 ms 80140 KB Output is correct
16 Correct 429 ms 80140 KB Output is correct
17 Correct 359 ms 80140 KB Output is correct
18 Correct 443 ms 80140 KB Output is correct
19 Correct 106 ms 80140 KB Output is correct
20 Correct 439 ms 80140 KB Output is correct
21 Correct 266 ms 80140 KB Output is correct
22 Correct 469 ms 80140 KB Output is correct
23 Correct 213 ms 80140 KB Output is correct
24 Correct 159 ms 80140 KB Output is correct
25 Correct 336 ms 80140 KB Output is correct
26 Correct 273 ms 80140 KB Output is correct
27 Correct 499 ms 80140 KB Output is correct
28 Correct 169 ms 80140 KB Output is correct
29 Correct 469 ms 80140 KB Output is correct
30 Correct 433 ms 80140 KB Output is correct
31 Correct 203 ms 80140 KB Output is correct
32 Correct 236 ms 80140 KB Output is correct
33 Correct 113 ms 80140 KB Output is correct
34 Correct 369 ms 80140 KB Output is correct
35 Correct 176 ms 80140 KB Output is correct
36 Correct 463 ms 80140 KB Output is correct
37 Correct 196 ms 80140 KB Output is correct
38 Correct 366 ms 80140 KB Output is correct
39 Correct 193 ms 80140 KB Output is correct
40 Correct 316 ms 80140 KB Output is correct
41 Correct 296 ms 80140 KB Output is correct
42 Correct 383 ms 80140 KB Output is correct