Submission #31885

#TimeUsernameProblemLanguageResultExecution timeMemory
31885aomeBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
533 ms80140 KiB
#include <bits/stdc++.h> using namespace std; const int M = 10000005; const int INF = 1e9; int n, q; int nxt[M], res[M]; int main() { scanf("%d %d", &n, &q); for (int i = 0; i < n; ++i) { int x; scanf("%d", &x); for (int j = 0; j < M; j += x) nxt[j] = max(nxt[j], x); } 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:11: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:13:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int x; scanf("%d", &x);
                               ^
brunhilda.cpp:26: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...