Submission #31884

#TimeUsernameProblemLanguageResultExecution timeMemory
31884aomeBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
483 ms89904 KiB
#include <bits/stdc++.h> using namespace std; const int M = 10000005; const int INF = 1e9; int n, q; int nxt[M], res[M]; bool in[M]; int main() { scanf("%d %d", &n, &q); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x), in[x] = 1; } for (int i = 2; i < M; ++i) { if (nxt[i] || !in[i]) continue; for (int j = 0; j < M; j += i) nxt[j] = max(nxt[j], i); } int cur = 0; for (int i = 1; i < M; ++i) { while (cur < i) { if (!nxt[cur] || cur + nxt[cur] <= i) cur++; else break; } if (cur == i) break; res[i] = res[cur] + 1; } while (q--) { int x; scanf("%d", &x); if (!res[x]) printf("oo\n"); else printf("%d\n", res[x]); } }

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:12:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &q);
                           ^
brunhilda.cpp:14:42: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x), in[x] = 1;
                                          ^
brunhilda.cpp:30:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                               ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...