# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
7851 |
2014-08-20T05:47:37 Z |
ainu7 |
경비원 (GA8_guard) |
C++ |
|
272 ms |
1864 KB |
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
const int mmod = 1000000007;
const int max_n = 2222;
const int small_cnt = 15;
const int small_prime[small_cnt] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
int main()
{
int n;
scanf("%d", &n);
vector<int> mask[max_n+1];
for (int i=0; i<n; i++) {
int temp;
scanf("%d", &temp);
int bit = 0;
for (int j=0; j<small_cnt; j++) {
int occ = 0;
while (temp % small_prime[j] == 0) {
occ = 1;
temp /= small_prime[j];
}
if (occ) bit |= 1 << j;
}
for (int j=50; j<=max_n; j++)
if (j * j == temp) temp = j;
mask[temp].push_back(bit);
}
int prv[1<<small_cnt] = {0};
prv[0] = 1;
// stage 1. mask[1]
for (int i=0; i<mask[1].size(); i++) {
int bit = mask[1][i];
for (int j=(1<<small_cnt)-1; j>=0; j--) {
if ((j&bit) == bit) {
prv[j] = prv[j] + prv[j-bit];
if (prv[j] >= mmod) prv[j] -= mmod;
}
}
}
// stage 2. mask[50++]
for (int i=50; i<=max_n; i++) {
if (!mask[i].size()) continue;
// select 0 or 1 of them.
int nxt[1<<small_cnt];
for (int j=0; j<(1<<small_cnt); j++) nxt[j] = prv[j];
for (int j=0; j<mask[i].size(); j++) {
int bit = mask[i][j];
for (int k=0; k<(1<<small_cnt); k++)
if ((k&bit) == bit) {
nxt[k] = nxt[k] + prv[k-bit];
if (nxt[k] >= mmod) nxt[k] -= mmod;
}
}
for (int j=0; j<(1<<small_cnt); j++) prv[j] = nxt[j];
}
int res = mmod - n - 1;
for (int i=0; i<(1<<small_cnt); i++)
res = (res + prv[i]) % mmod;
printf("%d\n", res);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1856 KB |
Output is correct |
2 |
Correct |
0 ms |
1856 KB |
Output is correct |
3 |
Correct |
0 ms |
1856 KB |
Output is correct |
4 |
Correct |
0 ms |
1864 KB |
Output is correct |
5 |
Correct |
0 ms |
1864 KB |
Output is correct |
6 |
Correct |
0 ms |
1864 KB |
Output is correct |
7 |
Correct |
0 ms |
1864 KB |
Output is correct |
8 |
Correct |
0 ms |
1860 KB |
Output is correct |
9 |
Correct |
0 ms |
1864 KB |
Output is correct |
10 |
Correct |
0 ms |
1864 KB |
Output is correct |
11 |
Correct |
0 ms |
1860 KB |
Output is correct |
12 |
Correct |
0 ms |
1856 KB |
Output is correct |
13 |
Correct |
0 ms |
1864 KB |
Output is correct |
14 |
Correct |
0 ms |
1864 KB |
Output is correct |
15 |
Correct |
0 ms |
1864 KB |
Output is correct |
16 |
Correct |
0 ms |
1860 KB |
Output is correct |
17 |
Correct |
0 ms |
1860 KB |
Output is correct |
18 |
Correct |
0 ms |
1856 KB |
Output is correct |
19 |
Correct |
0 ms |
1860 KB |
Output is correct |
20 |
Correct |
0 ms |
1856 KB |
Output is correct |
21 |
Correct |
0 ms |
1856 KB |
Output is correct |
22 |
Correct |
0 ms |
1864 KB |
Output is correct |
23 |
Correct |
0 ms |
1860 KB |
Output is correct |
24 |
Correct |
0 ms |
1860 KB |
Output is correct |
25 |
Correct |
0 ms |
1864 KB |
Output is correct |
26 |
Correct |
0 ms |
1860 KB |
Output is correct |
27 |
Correct |
0 ms |
1856 KB |
Output is correct |
28 |
Correct |
0 ms |
1860 KB |
Output is correct |
29 |
Correct |
0 ms |
1860 KB |
Output is correct |
30 |
Correct |
0 ms |
1864 KB |
Output is correct |
31 |
Correct |
0 ms |
1864 KB |
Output is correct |
32 |
Correct |
0 ms |
1856 KB |
Output is correct |
33 |
Correct |
0 ms |
1860 KB |
Output is correct |
34 |
Correct |
0 ms |
1864 KB |
Output is correct |
35 |
Correct |
0 ms |
1860 KB |
Output is correct |
36 |
Correct |
0 ms |
1864 KB |
Output is correct |
37 |
Correct |
0 ms |
1860 KB |
Output is correct |
38 |
Correct |
0 ms |
1860 KB |
Output is correct |
39 |
Correct |
0 ms |
1860 KB |
Output is correct |
40 |
Correct |
0 ms |
1860 KB |
Output is correct |
41 |
Correct |
0 ms |
1860 KB |
Output is correct |
42 |
Correct |
0 ms |
1860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
1864 KB |
Output is correct |
2 |
Correct |
0 ms |
1860 KB |
Output is correct |
3 |
Correct |
0 ms |
1860 KB |
Output is correct |
4 |
Correct |
0 ms |
1860 KB |
Output is correct |
5 |
Correct |
0 ms |
1860 KB |
Output is correct |
6 |
Correct |
0 ms |
1860 KB |
Output is correct |
7 |
Correct |
0 ms |
1864 KB |
Output is correct |
8 |
Correct |
0 ms |
1864 KB |
Output is correct |
9 |
Correct |
0 ms |
1856 KB |
Output is correct |
10 |
Correct |
0 ms |
1856 KB |
Output is correct |
11 |
Correct |
0 ms |
1864 KB |
Output is correct |
12 |
Correct |
0 ms |
1856 KB |
Output is correct |
13 |
Correct |
0 ms |
1864 KB |
Output is correct |
14 |
Correct |
0 ms |
1860 KB |
Output is correct |
15 |
Correct |
0 ms |
1864 KB |
Output is correct |
16 |
Correct |
0 ms |
1864 KB |
Output is correct |
17 |
Correct |
0 ms |
1864 KB |
Output is correct |
18 |
Correct |
0 ms |
1864 KB |
Output is correct |
19 |
Correct |
0 ms |
1860 KB |
Output is correct |
20 |
Correct |
0 ms |
1860 KB |
Output is correct |
21 |
Correct |
0 ms |
1860 KB |
Output is correct |
22 |
Correct |
0 ms |
1860 KB |
Output is correct |
23 |
Correct |
0 ms |
1864 KB |
Output is correct |
24 |
Correct |
0 ms |
1860 KB |
Output is correct |
25 |
Correct |
0 ms |
1864 KB |
Output is correct |
26 |
Correct |
0 ms |
1864 KB |
Output is correct |
27 |
Correct |
0 ms |
1860 KB |
Output is correct |
28 |
Correct |
0 ms |
1864 KB |
Output is correct |
29 |
Correct |
0 ms |
1864 KB |
Output is correct |
30 |
Correct |
0 ms |
1860 KB |
Output is correct |
31 |
Correct |
0 ms |
1864 KB |
Output is correct |
32 |
Correct |
0 ms |
1864 KB |
Output is correct |
33 |
Correct |
0 ms |
1864 KB |
Output is correct |
34 |
Correct |
0 ms |
1864 KB |
Output is correct |
35 |
Correct |
0 ms |
1860 KB |
Output is correct |
36 |
Correct |
0 ms |
1856 KB |
Output is correct |
37 |
Correct |
0 ms |
1856 KB |
Output is correct |
38 |
Correct |
0 ms |
1860 KB |
Output is correct |
39 |
Correct |
0 ms |
1860 KB |
Output is correct |
40 |
Correct |
0 ms |
1860 KB |
Output is correct |
41 |
Correct |
0 ms |
1864 KB |
Output is correct |
42 |
Correct |
0 ms |
1860 KB |
Output is correct |
43 |
Correct |
0 ms |
1856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
196 ms |
1860 KB |
Output is correct |
2 |
Correct |
196 ms |
1856 KB |
Output is correct |
3 |
Correct |
140 ms |
1860 KB |
Output is correct |
4 |
Correct |
124 ms |
1860 KB |
Output is correct |
5 |
Correct |
132 ms |
1864 KB |
Output is correct |
6 |
Correct |
124 ms |
1860 KB |
Output is correct |
7 |
Correct |
116 ms |
1860 KB |
Output is correct |
8 |
Correct |
120 ms |
1864 KB |
Output is correct |
9 |
Correct |
184 ms |
1860 KB |
Output is correct |
10 |
Correct |
188 ms |
1860 KB |
Output is correct |
11 |
Correct |
136 ms |
1860 KB |
Output is correct |
12 |
Correct |
120 ms |
1864 KB |
Output is correct |
13 |
Correct |
120 ms |
1860 KB |
Output is correct |
14 |
Correct |
116 ms |
1860 KB |
Output is correct |
15 |
Correct |
112 ms |
1856 KB |
Output is correct |
16 |
Correct |
112 ms |
1860 KB |
Output is correct |
17 |
Correct |
172 ms |
1860 KB |
Output is correct |
18 |
Correct |
168 ms |
1856 KB |
Output is correct |
19 |
Correct |
128 ms |
1860 KB |
Output is correct |
20 |
Correct |
108 ms |
1860 KB |
Output is correct |
21 |
Correct |
108 ms |
1860 KB |
Output is correct |
22 |
Correct |
100 ms |
1860 KB |
Output is correct |
23 |
Correct |
100 ms |
1856 KB |
Output is correct |
24 |
Correct |
104 ms |
1864 KB |
Output is correct |
25 |
Correct |
140 ms |
1864 KB |
Output is correct |
26 |
Correct |
140 ms |
1860 KB |
Output is correct |
27 |
Correct |
112 ms |
1864 KB |
Output is correct |
28 |
Correct |
92 ms |
1860 KB |
Output is correct |
29 |
Correct |
96 ms |
1860 KB |
Output is correct |
30 |
Correct |
84 ms |
1860 KB |
Output is correct |
31 |
Correct |
84 ms |
1860 KB |
Output is correct |
32 |
Correct |
88 ms |
1860 KB |
Output is correct |
33 |
Correct |
104 ms |
1860 KB |
Output is correct |
34 |
Correct |
104 ms |
1860 KB |
Output is correct |
35 |
Correct |
88 ms |
1860 KB |
Output is correct |
36 |
Correct |
68 ms |
1856 KB |
Output is correct |
37 |
Correct |
76 ms |
1860 KB |
Output is correct |
38 |
Correct |
68 ms |
1860 KB |
Output is correct |
39 |
Correct |
64 ms |
1864 KB |
Output is correct |
40 |
Correct |
64 ms |
1856 KB |
Output is correct |
41 |
Correct |
220 ms |
1864 KB |
Output is correct |
42 |
Correct |
216 ms |
1860 KB |
Output is correct |
43 |
Correct |
220 ms |
1864 KB |
Output is correct |
44 |
Correct |
216 ms |
1860 KB |
Output is correct |
45 |
Correct |
216 ms |
1864 KB |
Output is correct |
46 |
Correct |
216 ms |
1860 KB |
Output is correct |
47 |
Correct |
224 ms |
1864 KB |
Output is correct |
48 |
Correct |
216 ms |
1864 KB |
Output is correct |
49 |
Correct |
224 ms |
1864 KB |
Output is correct |
50 |
Correct |
216 ms |
1864 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
272 ms |
1860 KB |
Output is correct |
2 |
Correct |
260 ms |
1856 KB |
Output is correct |
3 |
Correct |
232 ms |
1860 KB |
Output is correct |
4 |
Correct |
188 ms |
1864 KB |
Output is correct |
5 |
Correct |
140 ms |
1864 KB |
Output is correct |
6 |
Correct |
140 ms |
1864 KB |
Output is correct |
7 |
Correct |
124 ms |
1856 KB |
Output is correct |
8 |
Correct |
132 ms |
1864 KB |
Output is correct |
9 |
Correct |
140 ms |
1864 KB |
Output is correct |
10 |
Correct |
140 ms |
1864 KB |
Output is correct |
11 |
Correct |
144 ms |
1860 KB |
Output is correct |
12 |
Correct |
72 ms |
1860 KB |
Output is correct |
13 |
Correct |
68 ms |
1856 KB |
Output is correct |
14 |
Correct |
68 ms |
1860 KB |
Output is correct |
15 |
Correct |
68 ms |
1864 KB |
Output is correct |
16 |
Correct |
72 ms |
1864 KB |
Output is correct |
17 |
Correct |
80 ms |
1860 KB |
Output is correct |
18 |
Correct |
72 ms |
1856 KB |
Output is correct |
19 |
Correct |
12 ms |
1860 KB |
Output is correct |
20 |
Correct |
12 ms |
1860 KB |
Output is correct |
21 |
Correct |
8 ms |
1860 KB |
Output is correct |
22 |
Correct |
12 ms |
1860 KB |
Output is correct |
23 |
Correct |
12 ms |
1860 KB |
Output is correct |
24 |
Correct |
12 ms |
1860 KB |
Output is correct |
25 |
Correct |
8 ms |
1860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
268 ms |
1860 KB |
Output is correct |
2 |
Correct |
256 ms |
1864 KB |
Output is correct |
3 |
Correct |
236 ms |
1860 KB |
Output is correct |
4 |
Correct |
212 ms |
1860 KB |
Output is correct |
5 |
Correct |
120 ms |
1864 KB |
Output is correct |
6 |
Correct |
120 ms |
1860 KB |
Output is correct |
7 |
Correct |
120 ms |
1860 KB |
Output is correct |
8 |
Correct |
116 ms |
1860 KB |
Output is correct |
9 |
Correct |
100 ms |
1864 KB |
Output is correct |
10 |
Correct |
120 ms |
1860 KB |
Output is correct |
11 |
Correct |
248 ms |
1860 KB |
Output is correct |
12 |
Correct |
252 ms |
1860 KB |
Output is correct |
13 |
Correct |
220 ms |
1864 KB |
Output is correct |
14 |
Correct |
204 ms |
1856 KB |
Output is correct |
15 |
Correct |
116 ms |
1856 KB |
Output is correct |
16 |
Correct |
116 ms |
1860 KB |
Output is correct |
17 |
Correct |
116 ms |
1860 KB |
Output is correct |
18 |
Correct |
116 ms |
1856 KB |
Output is correct |
19 |
Correct |
92 ms |
1864 KB |
Output is correct |
20 |
Correct |
120 ms |
1860 KB |
Output is correct |
21 |
Correct |
228 ms |
1860 KB |
Output is correct |
22 |
Correct |
236 ms |
1860 KB |
Output is correct |
23 |
Correct |
204 ms |
1860 KB |
Output is correct |
24 |
Correct |
184 ms |
1864 KB |
Output is correct |
25 |
Correct |
104 ms |
1864 KB |
Output is correct |
26 |
Correct |
104 ms |
1864 KB |
Output is correct |
27 |
Correct |
104 ms |
1856 KB |
Output is correct |
28 |
Correct |
104 ms |
1860 KB |
Output is correct |
29 |
Correct |
84 ms |
1864 KB |
Output is correct |
30 |
Correct |
104 ms |
1860 KB |
Output is correct |
31 |
Correct |
196 ms |
1864 KB |
Output is correct |
32 |
Correct |
196 ms |
1864 KB |
Output is correct |
33 |
Correct |
168 ms |
1860 KB |
Output is correct |
34 |
Correct |
152 ms |
1860 KB |
Output is correct |
35 |
Correct |
92 ms |
1864 KB |
Output is correct |
36 |
Correct |
92 ms |
1864 KB |
Output is correct |
37 |
Correct |
88 ms |
1864 KB |
Output is correct |
38 |
Correct |
88 ms |
1864 KB |
Output is correct |
39 |
Correct |
72 ms |
1864 KB |
Output is correct |
40 |
Correct |
92 ms |
1860 KB |
Output is correct |