답안 #92637

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
92637 2019-01-04T08:30:20 Z luckyboy Brunhilda’s Birthday (BOI13_brunhilda) C++14
5.55556 / 100
35 ms 3960 KB
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int  i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int  i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 100005
#define maxm 10000007
#define pii pair <int,int>
#define Task ""
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,q,a[maxn],tich = 1,dp[maxm];
int main()
{
    ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    cin >> n >> q;
    FOR(i,1,n)
    {
        cin >> a[i];
        if (1ll*tich*a[i] > 1e7)
        {
            tich = 1e7 + 1;
        }
        else tich *= a[i];
    }
    if (tich <= 1e7)
    {
        dp[0] = 0;
        FOR(i,1,tich - 1)
            {
                dp[i] = maxc;
                FOR(j,1,n)
                {
                    int x = i / a[j];
                    x *= a[j];
                    dp[i] = min(dp[i],dp[x] + 1);
                }
            }
    }
    while (q--)
    {
        int x;
        cin >> x;
        if (x >= tich)
        {
            cout << "oo\n";
        }
        else
        {
            cout << dp[x] << '\n';
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Correct 8 ms 1400 KB Output is correct
4 Incorrect 3 ms 504 KB Output isn't correct
5 Incorrect 2 ms 376 KB Output isn't correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 8 ms 1400 KB Output is correct
8 Correct 25 ms 3960 KB Output is correct
9 Incorrect 2 ms 420 KB Output isn't correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Incorrect 2 ms 376 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Incorrect 3 ms 504 KB Output isn't correct
15 Incorrect 2 ms 376 KB Output isn't correct
16 Incorrect 2 ms 376 KB Output isn't correct
17 Incorrect 3 ms 504 KB Output isn't correct
18 Incorrect 3 ms 376 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Incorrect 10 ms 1400 KB Output isn't correct
3 Incorrect 8 ms 1144 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 7 ms 888 KB Output isn't correct
6 Incorrect 2 ms 376 KB Output isn't correct
7 Incorrect 3 ms 504 KB Output isn't correct
8 Incorrect 2 ms 376 KB Output isn't correct
9 Incorrect 8 ms 1144 KB Output isn't correct
10 Incorrect 8 ms 1144 KB Output isn't correct
11 Incorrect 5 ms 760 KB Output isn't correct
12 Incorrect 2 ms 376 KB Output isn't correct
13 Incorrect 2 ms 376 KB Output isn't correct
14 Incorrect 2 ms 376 KB Output isn't correct
15 Incorrect 5 ms 760 KB Output isn't correct
16 Incorrect 11 ms 1400 KB Output isn't correct
17 Incorrect 2 ms 376 KB Output isn't correct
18 Incorrect 11 ms 1528 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 1364 KB Output isn't correct
2 Incorrect 18 ms 1144 KB Output isn't correct
3 Incorrect 16 ms 1400 KB Output isn't correct
4 Incorrect 25 ms 1272 KB Output isn't correct
5 Incorrect 28 ms 2424 KB Output isn't correct
6 Incorrect 26 ms 1400 KB Output isn't correct
7 Incorrect 21 ms 2012 KB Output isn't correct
8 Incorrect 17 ms 1400 KB Output isn't correct
9 Incorrect 17 ms 1364 KB Output isn't correct
10 Incorrect 10 ms 632 KB Output isn't correct
11 Incorrect 12 ms 760 KB Output isn't correct
12 Incorrect 13 ms 632 KB Output isn't correct
13 Incorrect 19 ms 1548 KB Output isn't correct
14 Incorrect 17 ms 1272 KB Output isn't correct
15 Incorrect 14 ms 760 KB Output isn't correct
16 Incorrect 13 ms 760 KB Output isn't correct
17 Incorrect 13 ms 1016 KB Output isn't correct
18 Incorrect 18 ms 1144 KB Output isn't correct
19 Incorrect 12 ms 632 KB Output isn't correct
20 Incorrect 15 ms 1400 KB Output isn't correct
21 Incorrect 18 ms 1400 KB Output isn't correct
22 Incorrect 30 ms 2424 KB Output isn't correct
23 Incorrect 23 ms 1656 KB Output isn't correct
24 Incorrect 26 ms 1400 KB Output isn't correct
25 Incorrect 26 ms 1400 KB Output isn't correct
26 Incorrect 25 ms 1400 KB Output isn't correct
27 Incorrect 20 ms 2040 KB Output isn't correct
28 Incorrect 18 ms 1400 KB Output isn't correct
29 Incorrect 30 ms 2424 KB Output isn't correct
30 Incorrect 28 ms 2040 KB Output isn't correct
31 Incorrect 24 ms 1272 KB Output isn't correct
32 Incorrect 26 ms 1272 KB Output isn't correct
33 Incorrect 25 ms 1272 KB Output isn't correct
34 Incorrect 20 ms 2044 KB Output isn't correct
35 Incorrect 18 ms 1400 KB Output isn't correct
36 Incorrect 35 ms 2420 KB Output isn't correct
37 Incorrect 28 ms 2424 KB Output isn't correct
38 Incorrect 26 ms 1400 KB Output isn't correct
39 Incorrect 26 ms 1404 KB Output isn't correct
40 Incorrect 26 ms 1400 KB Output isn't correct
41 Incorrect 20 ms 2040 KB Output isn't correct
42 Incorrect 18 ms 1372 KB Output isn't correct