#include <stdio.h>
bool chk[2223];
int pri[331];
int arr[2223];
bool sta[20];
bool tmp[331];
int mem[16384];
int n;
int g(int x,int y)
{
return x?g(y%x,x):y;
}
int f(int x)
{
if(x==n)
{
int s=0,i,j;
for(i=0;i<n;i++)
s+=sta[i];
if(s<2)
return 0;
for(i=0;i<n;i++)
if(sta[i])
for(j=i+1;j<n;j++)
if(sta[j]&&g(arr[i],arr[j])>1)
return 0;
return 1;
}
sta[x]=0;
int r=f(x+1);
sta[x]=1;
return f(x+1)+r;
}
int main()
{
int p=0,m=0,r=0,c,t,i,j;
const int mod=1000000007;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
if(n<=20)
{
printf("%d",f(0));
return 0;
}
for(i=0;i<n;i++)
m=arr[i]>m?arr[i]:m;
for(i=2;i<=m;i++)
{
if(!chk[i])
{
pri[p++]=i;
for(j=i*i;j<=m;j+=i)
chk[j]=1;
}
}
c=1<<p;
for(i=0;i<n;i++)
{
t=0;
for(j=0;j<p;j++)
{
if(arr[i]%pri[j]==0)
t|=1;
t<<=1;
}
t>>=1;
for(j=c-1;j>=0;j--)
{
if((t&j)==0)
{
mem[t|j]+=mem[j];
mem[t|j]%=mod;
}
}
mem[t]++;
}
for(i=0;i<c;i++)
{
r+=mem[i];
r%=mod;
}
printf("%d",r-n);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1164 KB |
Output is correct |
2 |
Correct |
0 ms |
1164 KB |
Output is correct |
3 |
Correct |
0 ms |
1164 KB |
Output is correct |
4 |
Correct |
0 ms |
1164 KB |
Output is correct |
5 |
Correct |
0 ms |
1164 KB |
Output is correct |
6 |
Correct |
0 ms |
1164 KB |
Output is correct |
7 |
Correct |
0 ms |
1164 KB |
Output is correct |
8 |
Correct |
0 ms |
1164 KB |
Output is correct |
9 |
Correct |
12 ms |
1164 KB |
Output is correct |
10 |
Correct |
0 ms |
1164 KB |
Output is correct |
11 |
Correct |
196 ms |
1164 KB |
Output is correct |
12 |
Correct |
44 ms |
1164 KB |
Output is correct |
13 |
Correct |
0 ms |
1164 KB |
Output is correct |
14 |
Correct |
0 ms |
1164 KB |
Output is correct |
15 |
Correct |
0 ms |
1164 KB |
Output is correct |
16 |
Correct |
0 ms |
1164 KB |
Output is correct |
17 |
Correct |
0 ms |
1164 KB |
Output is correct |
18 |
Correct |
0 ms |
1164 KB |
Output is correct |
19 |
Correct |
0 ms |
1164 KB |
Output is correct |
20 |
Correct |
0 ms |
1164 KB |
Output is correct |
21 |
Correct |
0 ms |
1164 KB |
Output is correct |
22 |
Correct |
0 ms |
1164 KB |
Output is correct |
23 |
Correct |
0 ms |
1164 KB |
Output is correct |
24 |
Correct |
0 ms |
1164 KB |
Output is correct |
25 |
Correct |
8 ms |
1164 KB |
Output is correct |
26 |
Correct |
0 ms |
1164 KB |
Output is correct |
27 |
Correct |
32 ms |
1164 KB |
Output is correct |
28 |
Correct |
52 ms |
1164 KB |
Output is correct |
29 |
Correct |
144 ms |
1164 KB |
Output is correct |
30 |
Correct |
760 ms |
1164 KB |
Output is correct |
31 |
Correct |
0 ms |
1164 KB |
Output is correct |
32 |
Correct |
0 ms |
1164 KB |
Output is correct |
33 |
Correct |
0 ms |
1164 KB |
Output is correct |
34 |
Correct |
0 ms |
1164 KB |
Output is correct |
35 |
Correct |
4 ms |
1164 KB |
Output is correct |
36 |
Correct |
176 ms |
1164 KB |
Output is correct |
37 |
Correct |
0 ms |
1164 KB |
Output is correct |
38 |
Correct |
0 ms |
1164 KB |
Output is correct |
39 |
Correct |
0 ms |
1164 KB |
Output is correct |
40 |
Correct |
0 ms |
1164 KB |
Output is correct |
41 |
Correct |
28 ms |
1164 KB |
Output is correct |
42 |
Correct |
608 ms |
1164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1164 KB |
Output is correct |
2 |
Correct |
0 ms |
1164 KB |
Output is correct |
3 |
Correct |
0 ms |
1164 KB |
Output is correct |
4 |
Correct |
0 ms |
1164 KB |
Output is correct |
5 |
Correct |
0 ms |
1164 KB |
Output is correct |
6 |
Correct |
0 ms |
1164 KB |
Output is correct |
7 |
Correct |
0 ms |
1164 KB |
Output is correct |
8 |
Correct |
0 ms |
1164 KB |
Output is correct |
9 |
Correct |
0 ms |
1164 KB |
Output is correct |
10 |
Correct |
0 ms |
1164 KB |
Output is correct |
11 |
Correct |
0 ms |
1164 KB |
Output is correct |
12 |
Correct |
0 ms |
1164 KB |
Output is correct |
13 |
Correct |
0 ms |
1164 KB |
Output is correct |
14 |
Correct |
4 ms |
1164 KB |
Output is correct |
15 |
Correct |
8 ms |
1164 KB |
Output is correct |
16 |
Correct |
12 ms |
1164 KB |
Output is correct |
17 |
Correct |
28 ms |
1164 KB |
Output is correct |
18 |
Correct |
60 ms |
1164 KB |
Output is correct |
19 |
Correct |
120 ms |
1164 KB |
Output is correct |
20 |
Correct |
0 ms |
1164 KB |
Output is correct |
21 |
Correct |
0 ms |
1164 KB |
Output is correct |
22 |
Correct |
0 ms |
1164 KB |
Output is correct |
23 |
Correct |
0 ms |
1164 KB |
Output is correct |
24 |
Correct |
0 ms |
1164 KB |
Output is correct |
25 |
Correct |
0 ms |
1164 KB |
Output is correct |
26 |
Correct |
0 ms |
1164 KB |
Output is correct |
27 |
Correct |
0 ms |
1164 KB |
Output is correct |
28 |
Correct |
0 ms |
1164 KB |
Output is correct |
29 |
Correct |
0 ms |
1164 KB |
Output is correct |
30 |
Correct |
0 ms |
1164 KB |
Output is correct |
31 |
Correct |
0 ms |
1164 KB |
Output is correct |
32 |
Correct |
0 ms |
1164 KB |
Output is correct |
33 |
Correct |
0 ms |
1164 KB |
Output is correct |
34 |
Correct |
0 ms |
1164 KB |
Output is correct |
35 |
Correct |
0 ms |
1164 KB |
Output is correct |
36 |
Correct |
0 ms |
1164 KB |
Output is correct |
37 |
Correct |
0 ms |
1164 KB |
Output is correct |
38 |
Correct |
0 ms |
1164 KB |
Output is correct |
39 |
Correct |
0 ms |
1164 KB |
Output is correct |
40 |
Correct |
0 ms |
1164 KB |
Output is correct |
41 |
Correct |
0 ms |
1164 KB |
Output is correct |
42 |
Correct |
0 ms |
1164 KB |
Output is correct |
43 |
Correct |
0 ms |
1164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
72 ms |
1164 KB |
Output is correct |
2 |
Correct |
68 ms |
1164 KB |
Output is correct |
3 |
Correct |
132 ms |
1164 KB |
Output is correct |
4 |
Correct |
68 ms |
1164 KB |
Output is correct |
5 |
Correct |
0 ms |
1164 KB |
Output is correct |
6 |
Correct |
0 ms |
1164 KB |
Output is correct |
7 |
Correct |
64 ms |
1164 KB |
Output is correct |
8 |
Correct |
64 ms |
1164 KB |
Output is correct |
9 |
Correct |
68 ms |
1164 KB |
Output is correct |
10 |
Correct |
68 ms |
1164 KB |
Output is correct |
11 |
Correct |
120 ms |
1164 KB |
Output is correct |
12 |
Correct |
64 ms |
1164 KB |
Output is correct |
13 |
Correct |
0 ms |
1164 KB |
Output is correct |
14 |
Correct |
0 ms |
1164 KB |
Output is correct |
15 |
Correct |
60 ms |
1164 KB |
Output is correct |
16 |
Correct |
60 ms |
1164 KB |
Output is correct |
17 |
Correct |
64 ms |
1164 KB |
Output is correct |
18 |
Correct |
64 ms |
1164 KB |
Output is correct |
19 |
Correct |
104 ms |
1164 KB |
Output is correct |
20 |
Correct |
60 ms |
1164 KB |
Output is correct |
21 |
Correct |
0 ms |
1164 KB |
Output is correct |
22 |
Correct |
0 ms |
1164 KB |
Output is correct |
23 |
Correct |
56 ms |
1164 KB |
Output is correct |
24 |
Correct |
56 ms |
1164 KB |
Output is correct |
25 |
Correct |
52 ms |
1164 KB |
Output is correct |
26 |
Correct |
52 ms |
1164 KB |
Output is correct |
27 |
Correct |
88 ms |
1164 KB |
Output is correct |
28 |
Correct |
48 ms |
1164 KB |
Output is correct |
29 |
Correct |
0 ms |
1164 KB |
Output is correct |
30 |
Correct |
0 ms |
1164 KB |
Output is correct |
31 |
Correct |
44 ms |
1164 KB |
Output is correct |
32 |
Correct |
44 ms |
1164 KB |
Output is correct |
33 |
Correct |
40 ms |
1164 KB |
Output is correct |
34 |
Correct |
40 ms |
1164 KB |
Output is correct |
35 |
Correct |
64 ms |
1164 KB |
Output is correct |
36 |
Correct |
36 ms |
1164 KB |
Output is correct |
37 |
Correct |
0 ms |
1164 KB |
Output is correct |
38 |
Correct |
0 ms |
1164 KB |
Output is correct |
39 |
Correct |
36 ms |
1164 KB |
Output is correct |
40 |
Correct |
36 ms |
1164 KB |
Output is correct |
41 |
Correct |
84 ms |
1164 KB |
Output is correct |
42 |
Correct |
80 ms |
1164 KB |
Output is correct |
43 |
Correct |
84 ms |
1164 KB |
Output is correct |
44 |
Correct |
84 ms |
1164 KB |
Output is correct |
45 |
Correct |
84 ms |
1164 KB |
Output is correct |
46 |
Correct |
84 ms |
1164 KB |
Output is correct |
47 |
Correct |
84 ms |
1164 KB |
Output is correct |
48 |
Correct |
84 ms |
1164 KB |
Output is correct |
49 |
Correct |
88 ms |
1164 KB |
Output is correct |
50 |
Correct |
80 ms |
1164 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
1160 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
0 ms |
1160 KB |
SIGSEGV Segmentation fault |
2 |
Halted |
0 ms |
0 KB |
- |