답안 #18639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
18639 2016-02-13T06:39:20 Z Namnamseo 경비원 (GA8_guard) C++14
13 / 100
603 ms 21780 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;
int getMaxDivisor(int x){
    for(int i=2;i*i<=x;++i) if(x%i==0) return x/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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1736 KB Output is correct
2 Correct 0 ms 1736 KB Output is correct
3 Correct 2 ms 1988 KB Output is correct
4 Correct 0 ms 1736 KB Output is correct
5 Correct 0 ms 1980 KB Output is correct
6 Incorrect 0 ms 2128 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1996 KB Output is correct
2 Correct 1 ms 1996 KB Output is correct
3 Correct 0 ms 1996 KB Output is correct
4 Correct 3 ms 1996 KB Output is correct
5 Correct 3 ms 1996 KB Output is correct
6 Correct 0 ms 1996 KB Output is correct
7 Correct 0 ms 1996 KB Output is correct
8 Correct 2 ms 1996 KB Output is correct
9 Correct 0 ms 1996 KB Output is correct
10 Correct 4 ms 1996 KB Output is correct
11 Correct 4 ms 1996 KB Output is correct
12 Correct 2 ms 1996 KB Output is correct
13 Correct 5 ms 1996 KB Output is correct
14 Correct 5 ms 1996 KB Output is correct
15 Correct 5 ms 1996 KB Output is correct
16 Correct 6 ms 1996 KB Output is correct
17 Correct 6 ms 1996 KB Output is correct
18 Correct 6 ms 1996 KB Output is correct
19 Correct 6 ms 1996 KB Output is correct
20 Correct 6 ms 1996 KB Output is correct
21 Correct 7 ms 1996 KB Output is correct
22 Correct 7 ms 1996 KB Output is correct
23 Correct 3 ms 1996 KB Output is correct
24 Correct 7 ms 2100 KB Output is correct
25 Correct 5 ms 2100 KB Output is correct
26 Correct 8 ms 2100 KB Output is correct
27 Correct 6 ms 2100 KB Output is correct
28 Correct 9 ms 2100 KB Output is correct
29 Correct 9 ms 2100 KB Output is correct
30 Correct 9 ms 2100 KB Output is correct
31 Correct 10 ms 2100 KB Output is correct
32 Correct 10 ms 2100 KB Output is correct
33 Correct 10 ms 2100 KB Output is correct
34 Correct 10 ms 2100 KB Output is correct
35 Correct 10 ms 2100 KB Output is correct
36 Correct 11 ms 2100 KB Output is correct
37 Correct 11 ms 2100 KB Output is correct
38 Correct 11 ms 2100 KB Output is correct
39 Correct 11 ms 2100 KB Output is correct
40 Correct 8 ms 2100 KB Output is correct
41 Correct 12 ms 2100 KB Output is correct
42 Correct 12 ms 2100 KB Output is correct
43 Correct 12 ms 2100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 566 ms 21780 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 601 ms 3720 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 603 ms 4020 KB Output isn't correct
2 Halted 0 ms 0 KB -