#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 dptmp[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 '?';
}
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;
dptmp[0]=1;
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){
dptmp[j]+=dp[j^mymask];
dptmp[j]%=M;
}
}
if(i+1==n || dd[i].first != dd[i+1].first){
for(j=0; j<32768; ++j) dp[j]=dptmp[j];
}
}
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 |
0 ms |
1364 KB |
Output is correct |
2 |
Correct |
0 ms |
1364 KB |
Output is correct |
3 |
Correct |
0 ms |
1364 KB |
Output is correct |
4 |
Correct |
0 ms |
1364 KB |
Output is correct |
5 |
Correct |
0 ms |
1364 KB |
Output is correct |
6 |
Correct |
0 ms |
1364 KB |
Output is correct |
7 |
Correct |
0 ms |
1364 KB |
Output is correct |
8 |
Correct |
0 ms |
1364 KB |
Output is correct |
9 |
Correct |
3 ms |
1364 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
3 ms |
1364 KB |
Output is correct |
12 |
Correct |
0 ms |
1364 KB |
Output is correct |
13 |
Correct |
1 ms |
1364 KB |
Output is correct |
14 |
Correct |
0 ms |
1364 KB |
Output is correct |
15 |
Incorrect |
0 ms |
1364 KB |
Output isn't correct |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1364 KB |
Output is correct |
2 |
Correct |
0 ms |
1364 KB |
Output is correct |
3 |
Correct |
0 ms |
1364 KB |
Output is correct |
4 |
Correct |
1 ms |
1364 KB |
Output is correct |
5 |
Correct |
0 ms |
1364 KB |
Output is correct |
6 |
Correct |
1 ms |
1364 KB |
Output is correct |
7 |
Correct |
2 ms |
1364 KB |
Output is correct |
8 |
Correct |
0 ms |
1364 KB |
Output is correct |
9 |
Correct |
2 ms |
1364 KB |
Output is correct |
10 |
Correct |
2 ms |
1364 KB |
Output is correct |
11 |
Correct |
2 ms |
1364 KB |
Output is correct |
12 |
Correct |
2 ms |
1364 KB |
Output is correct |
13 |
Correct |
0 ms |
1364 KB |
Output is correct |
14 |
Correct |
2 ms |
1364 KB |
Output is correct |
15 |
Correct |
0 ms |
1364 KB |
Output is correct |
16 |
Correct |
0 ms |
1364 KB |
Output is correct |
17 |
Correct |
2 ms |
1364 KB |
Output is correct |
18 |
Correct |
3 ms |
1364 KB |
Output is correct |
19 |
Correct |
0 ms |
1364 KB |
Output is correct |
20 |
Correct |
0 ms |
1364 KB |
Output is correct |
21 |
Correct |
3 ms |
1364 KB |
Output is correct |
22 |
Correct |
3 ms |
1364 KB |
Output is correct |
23 |
Correct |
3 ms |
1364 KB |
Output is correct |
24 |
Correct |
0 ms |
1364 KB |
Output is correct |
25 |
Correct |
3 ms |
1364 KB |
Output is correct |
26 |
Correct |
3 ms |
1364 KB |
Output is correct |
27 |
Correct |
3 ms |
1364 KB |
Output is correct |
28 |
Correct |
0 ms |
1364 KB |
Output is correct |
29 |
Correct |
0 ms |
1364 KB |
Output is correct |
30 |
Correct |
4 ms |
1364 KB |
Output is correct |
31 |
Correct |
4 ms |
1364 KB |
Output is correct |
32 |
Correct |
4 ms |
1364 KB |
Output is correct |
33 |
Correct |
4 ms |
1364 KB |
Output is correct |
34 |
Correct |
4 ms |
1364 KB |
Output is correct |
35 |
Correct |
4 ms |
1364 KB |
Output is correct |
36 |
Correct |
4 ms |
1364 KB |
Output is correct |
37 |
Correct |
4 ms |
1364 KB |
Output is correct |
38 |
Correct |
4 ms |
1364 KB |
Output is correct |
39 |
Correct |
4 ms |
1364 KB |
Output is correct |
40 |
Correct |
4 ms |
1364 KB |
Output is correct |
41 |
Correct |
2 ms |
1364 KB |
Output is correct |
42 |
Correct |
5 ms |
1364 KB |
Output is correct |
43 |
Correct |
5 ms |
1364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
185 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
226 ms |
1364 KB |
Output is correct |
2 |
Correct |
215 ms |
1364 KB |
Output is correct |
3 |
Correct |
197 ms |
1364 KB |
Output is correct |
4 |
Correct |
164 ms |
1364 KB |
Output is correct |
5 |
Correct |
124 ms |
1364 KB |
Output is correct |
6 |
Correct |
126 ms |
1364 KB |
Output is correct |
7 |
Correct |
128 ms |
1364 KB |
Output is correct |
8 |
Correct |
119 ms |
1364 KB |
Output is correct |
9 |
Correct |
125 ms |
1364 KB |
Output is correct |
10 |
Correct |
125 ms |
1364 KB |
Output is correct |
11 |
Correct |
126 ms |
1364 KB |
Output is correct |
12 |
Correct |
74 ms |
1364 KB |
Output is correct |
13 |
Correct |
76 ms |
1364 KB |
Output is correct |
14 |
Correct |
77 ms |
1364 KB |
Output is correct |
15 |
Correct |
75 ms |
1364 KB |
Output is correct |
16 |
Correct |
71 ms |
1364 KB |
Output is correct |
17 |
Correct |
76 ms |
1364 KB |
Output is correct |
18 |
Correct |
74 ms |
1364 KB |
Output is correct |
19 |
Correct |
18 ms |
1364 KB |
Output is correct |
20 |
Correct |
18 ms |
1364 KB |
Output is correct |
21 |
Correct |
18 ms |
1364 KB |
Output is correct |
22 |
Correct |
14 ms |
1364 KB |
Output is correct |
23 |
Correct |
17 ms |
1364 KB |
Output is correct |
24 |
Correct |
16 ms |
1364 KB |
Output is correct |
25 |
Correct |
17 ms |
1364 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
224 ms |
1364 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |