제출 #283091

#제출 시각아이디문제언어결과실행 시간메모리
283091egekabasBrunhilda’s Birthday (BOI13_brunhilda)C++14
7.78 / 100
1098 ms41080 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
int n, q;
int p[100009];
int ans[10000001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> q;
    for(int i = 0; i < n; ++i)
        cin >> p[i];
    reverse(p, p+n);
    ans[0] = 0;
    int lim = 1e7+1;
    for(int i = 1; i < lim; ++i){
        int goback = -1;
        for(int j = 0; j < n; ++j){
            if(i%p[j] <= goback)
                break;
            goback = i%p[j];
        }
        if(goback == 0){
            lim = i;
            break;
        }
        ans[i] = 1+ans[i-goback];
    }
    while(q--){
        int x;
        cin >> x;
        if(x >= lim)
            cout << "oo\n";
        else
            cout << ans[x] << '\n';
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...