Submission #155753

#TimeUsernameProblemLanguageResultExecution timeMemory
155753EntityITBrunhilda’s Birthday (BOI13_brunhilda)C++14
100 / 100
486 ms79224 KiB
#include<bits/stdc++.h>

using namespace std;

using LL = long long;
const int NPrime = (int)1e5 + 5, NQuery = NPrime, MAX = (int)1e7 + 5;
int nPrime, nQuery, maxPrime[MAX], f[MAX], LIM = 1;

int main() {
    scanf(" %d %d", &nPrime, &nQuery);
    for (int i = 1; i <= nPrime; ++i) {
        int p; scanf(" %d", &p);
        LIM = (int)min( (LL)MAX, (LL)LIM * p);
        for (int j = 0; j < MAX; j += p) maxPrime[j] = p;
    }

    int lst = 0, nxt = lst;
    for (int i = 0; i < LIM; ++i) {
        nxt = max(nxt, i + maxPrime[i] - 1);
        f[i + 1] = f[i];
        if (i == lst) {
            ++f[i + 1];
            lst = nxt;
        }
    }

    while (nQuery--) {
        int inp; scanf(" %d", &inp);
        if (inp >= LIM) printf("oo\n");
        else printf("%d\n", f[inp]);
    }

    return 0;
}

Compilation message (stderr)

brunhilda.cpp: In function 'int main()':
brunhilda.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf(" %d %d", &nPrime, &nQuery);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
brunhilda.cpp:12:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int p; scanf(" %d", &p);
                ~~~~~^~~~~~~~~~~
brunhilda.cpp:28:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         int inp; scanf(" %d", &inp);
                  ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...