Submission #92638

# Submission time Handle Problem Language Result Execution time Memory
92638 2019-01-04T08:33:04 Z luckyboy Brunhilda’s Birthday (BOI13_brunhilda) C++14
5.55556 / 100
45 ms 3832 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];
    sort(a+1,a+n+1);
    n = unique(a+1,a+n+1) - a - 1;
    FOR(i,1,n)
    {
        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;
}
# Verdict Execution time Memory 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 3832 KB Output is correct
9 Incorrect 2 ms 376 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 376 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 376 KB Output isn't correct
18 Incorrect 3 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 504 KB Output isn't correct
2 Incorrect 12 ms 768 KB Output isn't correct
3 Incorrect 9 ms 760 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 7 ms 632 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 9 ms 760 KB Output isn't correct
10 Incorrect 9 ms 760 KB Output isn't correct
11 Incorrect 6 ms 632 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 6 ms 676 KB Output isn't correct
16 Incorrect 11 ms 888 KB Output isn't correct
17 Incorrect 2 ms 376 KB Output isn't correct
18 Incorrect 12 ms 888 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 17 ms 760 KB Output isn't correct
2 Incorrect 19 ms 760 KB Output isn't correct
3 Incorrect 16 ms 760 KB Output isn't correct
4 Incorrect 25 ms 764 KB Output isn't correct
5 Incorrect 30 ms 1064 KB Output isn't correct
6 Incorrect 26 ms 760 KB Output isn't correct
7 Incorrect 21 ms 888 KB Output isn't correct
8 Incorrect 17 ms 760 KB Output isn't correct
9 Incorrect 17 ms 824 KB Output isn't correct
10 Incorrect 10 ms 504 KB Output isn't correct
11 Incorrect 13 ms 632 KB Output isn't correct
12 Incorrect 13 ms 632 KB Output isn't correct
13 Incorrect 19 ms 764 KB Output isn't correct
14 Incorrect 17 ms 632 KB Output isn't correct
15 Incorrect 13 ms 632 KB Output isn't correct
16 Incorrect 13 ms 632 KB Output isn't correct
17 Incorrect 13 ms 760 KB Output isn't correct
18 Incorrect 18 ms 760 KB Output isn't correct
19 Incorrect 13 ms 636 KB Output isn't correct
20 Incorrect 16 ms 760 KB Output isn't correct
21 Incorrect 18 ms 632 KB Output isn't correct
22 Incorrect 30 ms 1016 KB Output isn't correct
23 Incorrect 24 ms 760 KB Output isn't correct
24 Incorrect 25 ms 760 KB Output isn't correct
25 Incorrect 45 ms 760 KB Output isn't correct
26 Incorrect 24 ms 760 KB Output isn't correct
27 Incorrect 20 ms 1016 KB Output isn't correct
28 Incorrect 18 ms 760 KB Output isn't correct
29 Incorrect 30 ms 1144 KB Output isn't correct
30 Incorrect 27 ms 1016 KB Output isn't correct
31 Incorrect 24 ms 760 KB Output isn't correct
32 Incorrect 25 ms 760 KB Output isn't correct
33 Incorrect 24 ms 760 KB Output isn't correct
34 Incorrect 21 ms 1016 KB Output isn't correct
35 Incorrect 18 ms 632 KB Output isn't correct
36 Incorrect 35 ms 1144 KB Output isn't correct
37 Incorrect 29 ms 1144 KB Output isn't correct
38 Incorrect 25 ms 760 KB Output isn't correct
39 Incorrect 26 ms 888 KB Output isn't correct
40 Incorrect 25 ms 808 KB Output isn't correct
41 Incorrect 21 ms 1016 KB Output isn't correct
42 Incorrect 18 ms 760 KB Output isn't correct