#include <cstdio>
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];
int mask[2223];
int dp[1<<15];
int overcnt[2223];
int onecnt;
int sqn = 47;
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 main()
{
int i,j;
scanf("%d",&n);
for(i=0;i<n;++i){
scanf("%d",data+i);
if(data[i]==1) ++onecnt;
else {
if(data[i]>sqn && isprime(data[i])) ++overcnt[data[i]];
else {
for(j=0; j<pn; ++j){
if(data[i]%ps[j]==0){
mask[i]|=(1<<j);
}
}
}
}
}
dp[0]=1;
for(i=0;i<n;++i){
if(data[i]==1 || overcnt[data[i]]) continue;
int cm=mask[i];
for(j=0;j<32768;++j){
if((j&cm)==cm){
dp[j]+=dp[j^cm];
dp[j]%=M;
}
}
}
int asdf=1;
for(i=sqn+1;i<=2222;++i){
if(overcnt[i]){
asdf=(asdf*1LL*(overcnt[i]+1))%M;
}
}
for(;onecnt--;) asdf=(asdf*2)%M;
int fdsa=0;
for(i=0;i<32768;++i){
//if(dp[i]) printf("Mask %d : %d\n",i,dp[i]);
fdsa=(fdsa+dp[i])%M;
}
printf("%d\n",int((asdf*1LL*fdsa%M-n-1+M)%M));
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1236 KB |
Output is correct |
2 |
Correct |
1 ms |
1236 KB |
Output is correct |
3 |
Correct |
0 ms |
1236 KB |
Output is correct |
4 |
Correct |
0 ms |
1236 KB |
Output is correct |
5 |
Correct |
0 ms |
1236 KB |
Output is correct |
6 |
Incorrect |
1 ms |
1236 KB |
Output isn't correct |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1236 KB |
Output is correct |
2 |
Correct |
0 ms |
1236 KB |
Output is correct |
3 |
Correct |
0 ms |
1236 KB |
Output is correct |
4 |
Correct |
0 ms |
1236 KB |
Output is correct |
5 |
Correct |
0 ms |
1236 KB |
Output is correct |
6 |
Correct |
1 ms |
1236 KB |
Output is correct |
7 |
Correct |
1 ms |
1236 KB |
Output is correct |
8 |
Correct |
0 ms |
1236 KB |
Output is correct |
9 |
Correct |
2 ms |
1236 KB |
Output is correct |
10 |
Correct |
0 ms |
1236 KB |
Output is correct |
11 |
Correct |
2 ms |
1236 KB |
Output is correct |
12 |
Correct |
0 ms |
1236 KB |
Output is correct |
13 |
Correct |
0 ms |
1236 KB |
Output is correct |
14 |
Correct |
0 ms |
1236 KB |
Output is correct |
15 |
Correct |
2 ms |
1236 KB |
Output is correct |
16 |
Correct |
2 ms |
1236 KB |
Output is correct |
17 |
Correct |
2 ms |
1236 KB |
Output is correct |
18 |
Correct |
2 ms |
1236 KB |
Output is correct |
19 |
Correct |
0 ms |
1236 KB |
Output is correct |
20 |
Correct |
2 ms |
1236 KB |
Output is correct |
21 |
Correct |
3 ms |
1236 KB |
Output is correct |
22 |
Correct |
3 ms |
1236 KB |
Output is correct |
23 |
Correct |
3 ms |
1236 KB |
Output is correct |
24 |
Correct |
3 ms |
1236 KB |
Output is correct |
25 |
Correct |
0 ms |
1236 KB |
Output is correct |
26 |
Correct |
3 ms |
1236 KB |
Output is correct |
27 |
Correct |
3 ms |
1236 KB |
Output is correct |
28 |
Correct |
3 ms |
1236 KB |
Output is correct |
29 |
Correct |
4 ms |
1236 KB |
Output is correct |
30 |
Correct |
4 ms |
1236 KB |
Output is correct |
31 |
Correct |
0 ms |
1236 KB |
Output is correct |
32 |
Correct |
4 ms |
1236 KB |
Output is correct |
33 |
Correct |
4 ms |
1236 KB |
Output is correct |
34 |
Correct |
4 ms |
1236 KB |
Output is correct |
35 |
Correct |
4 ms |
1236 KB |
Output is correct |
36 |
Correct |
4 ms |
1236 KB |
Output is correct |
37 |
Correct |
4 ms |
1236 KB |
Output is correct |
38 |
Correct |
4 ms |
1236 KB |
Output is correct |
39 |
Correct |
4 ms |
1236 KB |
Output is correct |
40 |
Correct |
4 ms |
1236 KB |
Output is correct |
41 |
Correct |
4 ms |
1236 KB |
Output is correct |
42 |
Correct |
5 ms |
1236 KB |
Output is correct |
43 |
Correct |
5 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
206 ms |
1236 KB |
Output is correct |
2 |
Correct |
209 ms |
1236 KB |
Output is correct |
3 |
Correct |
10 ms |
1236 KB |
Output is correct |
4 |
Correct |
197 ms |
1236 KB |
Output is correct |
5 |
Correct |
137 ms |
1236 KB |
Output is correct |
6 |
Correct |
267 ms |
1236 KB |
Output is correct |
7 |
Correct |
195 ms |
1236 KB |
Output is correct |
8 |
Correct |
191 ms |
1236 KB |
Output is correct |
9 |
Correct |
200 ms |
1236 KB |
Output is correct |
10 |
Correct |
198 ms |
1236 KB |
Output is correct |
11 |
Correct |
19 ms |
1236 KB |
Output is correct |
12 |
Correct |
188 ms |
1236 KB |
Output is correct |
13 |
Correct |
123 ms |
1236 KB |
Output is correct |
14 |
Correct |
256 ms |
1236 KB |
Output is correct |
15 |
Correct |
188 ms |
1236 KB |
Output is correct |
16 |
Correct |
182 ms |
1236 KB |
Output is correct |
17 |
Correct |
182 ms |
1236 KB |
Output is correct |
18 |
Correct |
181 ms |
1236 KB |
Output is correct |
19 |
Correct |
27 ms |
1236 KB |
Output is correct |
20 |
Correct |
171 ms |
1236 KB |
Output is correct |
21 |
Correct |
122 ms |
1236 KB |
Output is correct |
22 |
Correct |
233 ms |
1236 KB |
Output is correct |
23 |
Correct |
171 ms |
1236 KB |
Output is correct |
24 |
Correct |
165 ms |
1236 KB |
Output is correct |
25 |
Correct |
154 ms |
1236 KB |
Output is correct |
26 |
Correct |
152 ms |
1236 KB |
Output is correct |
27 |
Correct |
36 ms |
1236 KB |
Output is correct |
28 |
Correct |
145 ms |
1236 KB |
Output is correct |
29 |
Correct |
95 ms |
1236 KB |
Output is correct |
30 |
Correct |
199 ms |
1236 KB |
Output is correct |
31 |
Correct |
145 ms |
1236 KB |
Output is correct |
32 |
Correct |
144 ms |
1236 KB |
Output is correct |
33 |
Correct |
121 ms |
1236 KB |
Output is correct |
34 |
Correct |
120 ms |
1236 KB |
Output is correct |
35 |
Correct |
43 ms |
1236 KB |
Output is correct |
36 |
Correct |
113 ms |
1236 KB |
Output is correct |
37 |
Correct |
81 ms |
1236 KB |
Output is correct |
38 |
Correct |
154 ms |
1236 KB |
Output is correct |
39 |
Correct |
113 ms |
1236 KB |
Output is correct |
40 |
Correct |
107 ms |
1236 KB |
Output is correct |
41 |
Correct |
238 ms |
1236 KB |
Output is correct |
42 |
Correct |
232 ms |
1236 KB |
Output is correct |
43 |
Correct |
244 ms |
1236 KB |
Output is correct |
44 |
Correct |
242 ms |
1236 KB |
Output is correct |
45 |
Correct |
239 ms |
1236 KB |
Output is correct |
46 |
Correct |
235 ms |
1236 KB |
Output is correct |
47 |
Correct |
246 ms |
1236 KB |
Output is correct |
48 |
Correct |
240 ms |
1236 KB |
Output is correct |
49 |
Correct |
246 ms |
1236 KB |
Output is correct |
50 |
Correct |
243 ms |
1236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
167 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |