답안 #305846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305846 2020-09-24T02:36:04 Z HynDuf Brunhilda’s Birthday (BOI13_brunhilda) C++11
100 / 100
607 ms 79224 KB
#include <bits/stdc++.h>

#define task "B"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vl;
const int N = 1e5 + 2, NN = 2e7 - 1;
int n, q, dp[NN + 2];
int main()
{
#ifdef HynDuf
    freopen(task".in", "r", stdin);
    //freopen(task".out", "w", stdout);
#else
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
    cin >> n >> q;
    ll lcm = 1;
    rep(i, 1, n)
    {
        int p;
        cin >> p;
        for (int j = p - 1; j <= NN; j += p) dp[j] = p - 1;
        lcm = min(N * 100LL, lcm * p);
    }
    Rep(i, NN - 1, 1) dp[i] = max(dp[i], dp[i + 1] - 1);
    rep(i, 1, NN) dp[i] = dp[i - dp[i]] + 1;
    while (q--)
    {
        int x;
        cin >> x;
        if (x >= lcm) cout << "oo\n";
        else cout << dp[x] << '\n';
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 163 ms 78584 KB Output is correct
2 Correct 205 ms 78712 KB Output is correct
3 Correct 182 ms 78584 KB Output is correct
4 Correct 165 ms 78588 KB Output is correct
5 Correct 191 ms 78720 KB Output is correct
6 Correct 164 ms 78712 KB Output is correct
7 Correct 185 ms 78712 KB Output is correct
8 Correct 192 ms 78712 KB Output is correct
9 Correct 229 ms 78712 KB Output is correct
10 Correct 273 ms 78592 KB Output is correct
11 Correct 257 ms 78712 KB Output is correct
12 Correct 163 ms 78592 KB Output is correct
13 Correct 456 ms 78668 KB Output is correct
14 Correct 446 ms 78624 KB Output is correct
15 Correct 229 ms 78712 KB Output is correct
16 Correct 208 ms 78684 KB Output is correct
17 Correct 214 ms 78712 KB Output is correct
18 Correct 171 ms 78712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 201 ms 78664 KB Output is correct
2 Correct 223 ms 78584 KB Output is correct
3 Correct 582 ms 78652 KB Output is correct
4 Correct 242 ms 78584 KB Output is correct
5 Correct 406 ms 78712 KB Output is correct
6 Correct 204 ms 78712 KB Output is correct
7 Correct 191 ms 78716 KB Output is correct
8 Correct 239 ms 78592 KB Output is correct
9 Correct 450 ms 78584 KB Output is correct
10 Correct 556 ms 78712 KB Output is correct
11 Correct 542 ms 78712 KB Output is correct
12 Correct 306 ms 78584 KB Output is correct
13 Correct 174 ms 78584 KB Output is correct
14 Correct 241 ms 78584 KB Output is correct
15 Correct 451 ms 78712 KB Output is correct
16 Correct 224 ms 78776 KB Output is correct
17 Correct 471 ms 78584 KB Output is correct
18 Correct 460 ms 78712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 458 ms 78840 KB Output is correct
2 Correct 566 ms 78712 KB Output is correct
3 Correct 560 ms 78840 KB Output is correct
4 Correct 348 ms 78916 KB Output is correct
5 Correct 267 ms 78844 KB Output is correct
6 Correct 468 ms 78840 KB Output is correct
7 Correct 417 ms 78712 KB Output is correct
8 Correct 461 ms 78712 KB Output is correct
9 Correct 454 ms 78712 KB Output is correct
10 Correct 371 ms 78660 KB Output is correct
11 Correct 314 ms 78712 KB Output is correct
12 Correct 426 ms 78840 KB Output is correct
13 Correct 555 ms 78920 KB Output is correct
14 Correct 314 ms 79212 KB Output is correct
15 Correct 449 ms 78664 KB Output is correct
16 Correct 505 ms 78664 KB Output is correct
17 Correct 456 ms 78852 KB Output is correct
18 Correct 583 ms 78712 KB Output is correct
19 Correct 193 ms 78716 KB Output is correct
20 Correct 580 ms 78840 KB Output is correct
21 Correct 358 ms 79224 KB Output is correct
22 Correct 584 ms 78840 KB Output is correct
23 Correct 265 ms 78840 KB Output is correct
24 Correct 214 ms 78916 KB Output is correct
25 Correct 375 ms 78968 KB Output is correct
26 Correct 335 ms 78876 KB Output is correct
27 Correct 607 ms 78712 KB Output is correct
28 Correct 212 ms 78968 KB Output is correct
29 Correct 548 ms 78840 KB Output is correct
30 Correct 495 ms 78840 KB Output is correct
31 Correct 246 ms 78840 KB Output is correct
32 Correct 274 ms 78968 KB Output is correct
33 Correct 191 ms 79052 KB Output is correct
34 Correct 414 ms 78840 KB Output is correct
35 Correct 231 ms 79096 KB Output is correct
36 Correct 564 ms 78792 KB Output is correct
37 Correct 270 ms 78832 KB Output is correct
38 Correct 466 ms 78920 KB Output is correct
39 Correct 235 ms 79044 KB Output is correct
40 Correct 405 ms 78968 KB Output is correct
41 Correct 355 ms 78696 KB Output is correct
42 Correct 513 ms 79224 KB Output is correct