# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
77371 | xiaowuc1 | Brunhilda’s Birthday (BOI13_brunhilda) | C++14 | 69 ms | 39564 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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);
}
}
}
컴파일 시 표준 에러 (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... |