Submission #18640

# Submission time Handle Problem Language Result Execution time Memory
18640 2016-02-13T06:42:24 Z Namnamseo 경비원 (GA8_guard) C++14
13 / 100
605 ms 32768 KB
#include <cstdio>
#include <algorithm>
#include <queue>
int ps[]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int pn=15;
int n;
int data[2223];
typedef std::pair<int,int> pp;
pp dd[2223];
int dp[1<<15];
int M=int(1e9)+7;
bool isprime(int x){
    for(int i=2;i*i<=x;++i) if(x%i==0) return 0;
    return 1;
}
int getMaxDivisor(int x){
    for(int i=x;i>=1;--i) if(x%i==0 && isprime(i)) return i;
    return x;
}
int main()
{
    int i,j;
    scanf("%d",&n);
    for(i=0;i<n;++i){
        scanf("%d",data+i);
        dd[i]={getMaxDivisor(data[i]),data[i]};
    }
    std::sort(dd,dd+n);
    dp[0]=1;
    std::queue<pp> pending;
    for(i=0;i<n;++i){
        int mymask = 0;
        int myval  = dd[i].second;
        for(j=0; j<pn; ++j) if(myval % ps[j]==0) mymask |= (1<<j);
        for(j=0; j<32768; ++j){
            if((j&mymask) == mymask){
                pending.push({j, dp[j^mymask]});
            }
        }
        if(i+1==n || dd[i].first != dd[i+1].first){
            while(pending.size()){
                pp& tmp=pending.front();
                dp[tmp.first]+=tmp.second;
                dp[tmp.first]%=M;
                pending.pop();
            }
        }
    }
    int ans=0;
    for(i=0; i<32768; ++i) ans+=dp[i], ans%=M;
    printf("%d\n",(ans-n-1+M)%M);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1736 KB Output is correct
2 Correct 0 ms 1736 KB Output is correct
3 Correct 0 ms 1984 KB Output is correct
4 Correct 0 ms 1868 KB Output is correct
5 Correct 0 ms 1984 KB Output is correct
6 Correct 0 ms 2396 KB Output is correct
7 Correct 3 ms 1976 KB Output is correct
8 Correct 0 ms 2944 KB Output is correct
9 Correct 6 ms 1960 KB Output is correct
10 Correct 5 ms 3208 KB Output is correct
11 Correct 6 ms 1976 KB Output is correct
12 Correct 0 ms 2260 KB Output is correct
13 Correct 0 ms 1864 KB Output is correct
14 Correct 0 ms 2000 KB Output is correct
15 Incorrect 2 ms 2264 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1996 KB Output is correct
2 Correct 0 ms 1996 KB Output is correct
3 Correct 0 ms 1996 KB Output is correct
4 Correct 2 ms 1996 KB Output is correct
5 Correct 3 ms 1996 KB Output is correct
6 Correct 3 ms 1996 KB Output is correct
7 Correct 3 ms 2128 KB Output is correct
8 Correct 4 ms 2128 KB Output is correct
9 Correct 0 ms 2128 KB Output is correct
10 Correct 2 ms 2128 KB Output is correct
11 Correct 4 ms 2128 KB Output is correct
12 Correct 0 ms 2128 KB Output is correct
13 Correct 3 ms 2128 KB Output is correct
14 Correct 3 ms 2128 KB Output is correct
15 Correct 5 ms 2260 KB Output is correct
16 Correct 6 ms 2260 KB Output is correct
17 Correct 6 ms 2260 KB Output is correct
18 Correct 6 ms 2260 KB Output is correct
19 Correct 6 ms 2260 KB Output is correct
20 Correct 7 ms 2260 KB Output is correct
21 Correct 7 ms 2260 KB Output is correct
22 Correct 7 ms 2260 KB Output is correct
23 Correct 3 ms 2260 KB Output is correct
24 Correct 8 ms 2260 KB Output is correct
25 Correct 8 ms 2260 KB Output is correct
26 Correct 8 ms 2392 KB Output is correct
27 Correct 8 ms 2392 KB Output is correct
28 Correct 9 ms 2392 KB Output is correct
29 Correct 9 ms 2392 KB Output is correct
30 Correct 9 ms 2392 KB Output is correct
31 Correct 9 ms 2392 KB Output is correct
32 Correct 10 ms 2392 KB Output is correct
33 Correct 10 ms 2392 KB Output is correct
34 Correct 7 ms 2392 KB Output is correct
35 Correct 10 ms 2392 KB Output is correct
36 Correct 10 ms 2392 KB Output is correct
37 Correct 11 ms 2392 KB Output is correct
38 Correct 11 ms 2392 KB Output is correct
39 Correct 11 ms 2392 KB Output is correct
40 Correct 11 ms 2392 KB Output is correct
41 Correct 11 ms 2392 KB Output is correct
42 Correct 8 ms 2392 KB Output is correct
43 Correct 12 ms 2392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Memory limit exceeded 92 ms 32768 KB Memory limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 605 ms 6020 KB Output is correct
2 Correct 583 ms 5956 KB Output is correct
3 Correct 534 ms 5724 KB Output is correct
4 Correct 432 ms 5380 KB Output is correct
5 Correct 322 ms 4216 KB Output is correct
6 Correct 330 ms 4404 KB Output is correct
7 Incorrect 332 ms 3960 KB Output isn't correct - wrong output format : File not found: "/var/www/temp/18640/output7oV4_1"
8 Halted 0 ms 0 KB -
9 Correct 328 ms 4580 KB Output is correct
10 Correct 329 ms 4448 KB Output is correct
11 Correct 334 ms 4316 KB Output is correct
12 Correct 196 ms 3268 KB Output is correct
13 Correct 196 ms 2968 KB Output is correct
14 Correct 198 ms 3520 KB Output is correct
15 Correct 197 ms 3092 KB Output is correct
16 Correct 192 ms 4052 KB Output is correct
17 Correct 196 ms 3744 KB Output is correct
18 Correct 196 ms 3092 KB Output is correct
19 Correct 49 ms 2368 KB Output is correct
20 Correct 47 ms 2320 KB Output is correct
21 Correct 45 ms 2080 KB Output is correct
22 Correct 45 ms 2172 KB Output is correct
23 Correct 47 ms 2264 KB Output is correct
24 Correct 43 ms 2260 KB Output is correct
25 Correct 46 ms 2240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Halted 0 ms 0 KB
2 Halted 0 ms 0 KB -