# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77371 | xiaowuc1 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 69 ms | 39564 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/
using namespace std;
const double PI = 2 * acos(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;
typedef vector<vector<ll>> matrix;
int primes[100000];
int thresh[10000000];
int main() {
int n;
int q;
scanf("%d%d", &n, &q);
for(int i = n-1; i >= 0; i--) {
scanf("%d", &primes[i]);
}
thresh[1] = primes[0]-1;
int ans = 2;
while(thresh[ans-1] <= 10000000) {
int last = thresh[ans-1];
int best = last;
for(int i = 0; i < n; i++) {
if((last+1)%primes[i] == 0) continue;
int t = last - (last) % primes[i] + primes[i] - 1;
if(t > best) {
best = t;
}
if(last + primes[i] - 1 <= best) break;
}
if(last == best) break;
thresh[ans++] = best;
last = best;
}
ans--;
while(q--) {
int goal;
scanf("%d", &goal);
if(goal > thresh[ans]) {
printf("oo\n");
}
else {
int lhs = 1;
int rhs = ans;
while(lhs != rhs) {
int mid = (lhs+rhs)/2;
if(thresh[mid] < goal) lhs = mid+1;
else rhs = mid;
}
printf("%d\n", lhs);
}
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |