이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("03")
#define int long long
#define ll long long
#define pii pair<int, int>
#define F first
#define S second
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
#define NYOOM ios::sync_with_stdio(0); cin.tie(0);
#define endl '\n'
const int INF = 1e9 + 7;
const ll LLINF = 1ll<<60;
const int maxn = 1e8 + 10;
signed main(){
int m, q; cin >> m >> q;
int p[m]; FOR(i, m) cin >> p[i];
vector<int> x; int mx = LLINF;
int last = 1; x.PB(1);
while (last < maxn){
int next = -1;
FOR(i, m){
int val = ((last - 1) / p[i] + 1) * p[i];
next = max(next, val);
}
x.PB(next);
if (next == last){
mx = next;
break;
}
last = next;
}
while (q--){
int n; cin >> n;
if (n >= mx){
cout << "oo" << endl;
continue;
}
int idx = upper_bound(ALL(x), n) - x.begin();
cout << idx << endl;
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |