# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
7872 |
2014-08-21T00:12:42 Z |
tncks0121 |
경비원 (GA8_guard) |
C++ |
|
200 ms |
1624 KB |
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <deque>
#include <utility>
#include <bitset>
#include <limits.h>
using namespace std;
typedef long long ll;
typedef unsigned long long llu;
typedef double lf;
typedef unsigned int uint;
typedef long double llf;
typedef pair<int, int> pii;
const int N_ = 2225, SZ = 2222;
const int PN = 15;
const int P[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
const int MOD = (int)1e9 + 7;
int N, freq[SZ+10];
ll Table[1 << PN], Table_prev[1 << PN];
int A[SZ+10], D[SZ+10];
ll res = 0;
ll ones = 0;
int main() {
scanf("%d", &N);
for(int i = 1; i <= N; i++) {
int x; scanf("%d", &x);
++freq[x];
}
for(int n = 1; n <= SZ; n++) D[n] = n;
for(int i = 0; i < PN; i++) {
for(int n = P[i]; n <= SZ; n += P[i]) {
A[n] |= 1<<i;
while(D[n] % P[i] == 0) D[n] /= P[i];
}
}
Table[0] = 1;
for(int i = 0; i < freq[1]; i++) Table[0] = (Table[0] * 2) % MOD;
for(int n = 2; n <= SZ; n++) if(freq[n] != 0 && D[n] == 1) {
for(int state = 0; state < (1<<PN); state++) if((state & A[n]) == 0) {
ll &v = Table[state | A[n]];
v += Table[state] * freq[n]; v %= MOD;
}
}
for(int d = P[PN-1]+1; d <= SZ; d++) if(A[d] == 0) {
for(int state = 0; state < (1<<PN); state++) Table_prev[state] = Table[state];
for(int n = d, k = 1; n <= SZ; n += d, k++) if(freq[n] != 0) {
for(int state = 0; state < (1<<PN); state++) if((state & A[k]) == 0) {
ll &v = Table[state | A[k]];
v += Table_prev[state] * freq[n]; v %= MOD;
}
}
}
res = 0;
for(int state = 0; state < (1<<PN); state++) res = (res + Table[state]) % MOD;
res -= (N + 1);
res = (res + MOD) % MOD;
printf("%lld\n", res);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1624 KB |
Output is correct |
2 |
Correct |
8 ms |
1624 KB |
Output is correct |
3 |
Correct |
12 ms |
1624 KB |
Output is correct |
4 |
Correct |
8 ms |
1624 KB |
Output is correct |
5 |
Correct |
12 ms |
1624 KB |
Output is correct |
6 |
Correct |
12 ms |
1624 KB |
Output is correct |
7 |
Correct |
12 ms |
1624 KB |
Output is correct |
8 |
Correct |
12 ms |
1624 KB |
Output is correct |
9 |
Correct |
12 ms |
1624 KB |
Output is correct |
10 |
Correct |
12 ms |
1624 KB |
Output is correct |
11 |
Correct |
12 ms |
1624 KB |
Output is correct |
12 |
Correct |
12 ms |
1624 KB |
Output is correct |
13 |
Correct |
12 ms |
1624 KB |
Output is correct |
14 |
Correct |
8 ms |
1624 KB |
Output is correct |
15 |
Correct |
8 ms |
1624 KB |
Output is correct |
16 |
Correct |
12 ms |
1624 KB |
Output is correct |
17 |
Correct |
12 ms |
1624 KB |
Output is correct |
18 |
Correct |
8 ms |
1624 KB |
Output is correct |
19 |
Correct |
12 ms |
1624 KB |
Output is correct |
20 |
Correct |
12 ms |
1624 KB |
Output is correct |
21 |
Correct |
8 ms |
1624 KB |
Output is correct |
22 |
Correct |
12 ms |
1624 KB |
Output is correct |
23 |
Correct |
8 ms |
1624 KB |
Output is correct |
24 |
Correct |
8 ms |
1624 KB |
Output is correct |
25 |
Correct |
12 ms |
1624 KB |
Output is correct |
26 |
Correct |
12 ms |
1624 KB |
Output is correct |
27 |
Correct |
8 ms |
1624 KB |
Output is correct |
28 |
Correct |
12 ms |
1624 KB |
Output is correct |
29 |
Correct |
12 ms |
1624 KB |
Output is correct |
30 |
Correct |
8 ms |
1624 KB |
Output is correct |
31 |
Correct |
8 ms |
1624 KB |
Output is correct |
32 |
Correct |
12 ms |
1624 KB |
Output is correct |
33 |
Correct |
12 ms |
1624 KB |
Output is correct |
34 |
Correct |
12 ms |
1624 KB |
Output is correct |
35 |
Correct |
12 ms |
1624 KB |
Output is correct |
36 |
Correct |
12 ms |
1624 KB |
Output is correct |
37 |
Correct |
8 ms |
1624 KB |
Output is correct |
38 |
Correct |
8 ms |
1624 KB |
Output is correct |
39 |
Correct |
12 ms |
1624 KB |
Output is correct |
40 |
Correct |
4 ms |
1624 KB |
Output is correct |
41 |
Correct |
12 ms |
1624 KB |
Output is correct |
42 |
Correct |
12 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1624 KB |
Output is correct |
2 |
Correct |
12 ms |
1624 KB |
Output is correct |
3 |
Correct |
12 ms |
1624 KB |
Output is correct |
4 |
Correct |
12 ms |
1624 KB |
Output is correct |
5 |
Correct |
12 ms |
1624 KB |
Output is correct |
6 |
Correct |
12 ms |
1624 KB |
Output is correct |
7 |
Correct |
12 ms |
1624 KB |
Output is correct |
8 |
Correct |
12 ms |
1624 KB |
Output is correct |
9 |
Correct |
12 ms |
1624 KB |
Output is correct |
10 |
Correct |
8 ms |
1624 KB |
Output is correct |
11 |
Correct |
12 ms |
1624 KB |
Output is correct |
12 |
Correct |
8 ms |
1624 KB |
Output is correct |
13 |
Correct |
12 ms |
1624 KB |
Output is correct |
14 |
Correct |
8 ms |
1624 KB |
Output is correct |
15 |
Correct |
12 ms |
1624 KB |
Output is correct |
16 |
Correct |
12 ms |
1624 KB |
Output is correct |
17 |
Correct |
12 ms |
1624 KB |
Output is correct |
18 |
Correct |
8 ms |
1624 KB |
Output is correct |
19 |
Correct |
12 ms |
1624 KB |
Output is correct |
20 |
Correct |
12 ms |
1624 KB |
Output is correct |
21 |
Correct |
12 ms |
1624 KB |
Output is correct |
22 |
Correct |
12 ms |
1624 KB |
Output is correct |
23 |
Correct |
12 ms |
1624 KB |
Output is correct |
24 |
Correct |
12 ms |
1624 KB |
Output is correct |
25 |
Correct |
12 ms |
1624 KB |
Output is correct |
26 |
Correct |
12 ms |
1624 KB |
Output is correct |
27 |
Correct |
12 ms |
1624 KB |
Output is correct |
28 |
Correct |
8 ms |
1624 KB |
Output is correct |
29 |
Correct |
12 ms |
1624 KB |
Output is correct |
30 |
Correct |
12 ms |
1624 KB |
Output is correct |
31 |
Correct |
12 ms |
1624 KB |
Output is correct |
32 |
Correct |
12 ms |
1624 KB |
Output is correct |
33 |
Correct |
12 ms |
1624 KB |
Output is correct |
34 |
Correct |
12 ms |
1624 KB |
Output is correct |
35 |
Correct |
12 ms |
1624 KB |
Output is correct |
36 |
Correct |
12 ms |
1624 KB |
Output is correct |
37 |
Correct |
8 ms |
1624 KB |
Output is correct |
38 |
Correct |
12 ms |
1624 KB |
Output is correct |
39 |
Correct |
12 ms |
1624 KB |
Output is correct |
40 |
Correct |
12 ms |
1624 KB |
Output is correct |
41 |
Correct |
12 ms |
1624 KB |
Output is correct |
42 |
Correct |
12 ms |
1624 KB |
Output is correct |
43 |
Correct |
12 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
1624 KB |
Output is correct |
2 |
Correct |
16 ms |
1624 KB |
Output is correct |
3 |
Correct |
12 ms |
1624 KB |
Output is correct |
4 |
Correct |
12 ms |
1624 KB |
Output is correct |
5 |
Correct |
12 ms |
1624 KB |
Output is correct |
6 |
Correct |
12 ms |
1624 KB |
Output is correct |
7 |
Correct |
8 ms |
1624 KB |
Output is correct |
8 |
Correct |
12 ms |
1624 KB |
Output is correct |
9 |
Correct |
8 ms |
1624 KB |
Output is correct |
10 |
Correct |
16 ms |
1624 KB |
Output is correct |
11 |
Correct |
12 ms |
1624 KB |
Output is correct |
12 |
Correct |
12 ms |
1624 KB |
Output is correct |
13 |
Correct |
12 ms |
1624 KB |
Output is correct |
14 |
Correct |
12 ms |
1624 KB |
Output is correct |
15 |
Correct |
12 ms |
1624 KB |
Output is correct |
16 |
Correct |
12 ms |
1624 KB |
Output is correct |
17 |
Correct |
12 ms |
1624 KB |
Output is correct |
18 |
Correct |
8 ms |
1624 KB |
Output is correct |
19 |
Correct |
12 ms |
1624 KB |
Output is correct |
20 |
Correct |
12 ms |
1624 KB |
Output is correct |
21 |
Correct |
12 ms |
1624 KB |
Output is correct |
22 |
Correct |
12 ms |
1624 KB |
Output is correct |
23 |
Correct |
8 ms |
1624 KB |
Output is correct |
24 |
Correct |
12 ms |
1624 KB |
Output is correct |
25 |
Correct |
12 ms |
1624 KB |
Output is correct |
26 |
Correct |
12 ms |
1624 KB |
Output is correct |
27 |
Correct |
12 ms |
1624 KB |
Output is correct |
28 |
Correct |
12 ms |
1624 KB |
Output is correct |
29 |
Correct |
12 ms |
1624 KB |
Output is correct |
30 |
Correct |
12 ms |
1624 KB |
Output is correct |
31 |
Correct |
12 ms |
1624 KB |
Output is correct |
32 |
Correct |
12 ms |
1624 KB |
Output is correct |
33 |
Correct |
12 ms |
1624 KB |
Output is correct |
34 |
Correct |
12 ms |
1624 KB |
Output is correct |
35 |
Correct |
12 ms |
1624 KB |
Output is correct |
36 |
Correct |
12 ms |
1624 KB |
Output is correct |
37 |
Correct |
12 ms |
1624 KB |
Output is correct |
38 |
Correct |
12 ms |
1624 KB |
Output is correct |
39 |
Correct |
12 ms |
1624 KB |
Output is correct |
40 |
Correct |
12 ms |
1624 KB |
Output is correct |
41 |
Correct |
12 ms |
1624 KB |
Output is correct |
42 |
Correct |
8 ms |
1624 KB |
Output is correct |
43 |
Correct |
12 ms |
1624 KB |
Output is correct |
44 |
Correct |
12 ms |
1624 KB |
Output is correct |
45 |
Correct |
12 ms |
1624 KB |
Output is correct |
46 |
Correct |
8 ms |
1624 KB |
Output is correct |
47 |
Correct |
12 ms |
1624 KB |
Output is correct |
48 |
Correct |
12 ms |
1624 KB |
Output is correct |
49 |
Correct |
12 ms |
1624 KB |
Output is correct |
50 |
Correct |
12 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
200 ms |
1624 KB |
Output is correct |
2 |
Correct |
192 ms |
1624 KB |
Output is correct |
3 |
Correct |
176 ms |
1624 KB |
Output is correct |
4 |
Correct |
152 ms |
1624 KB |
Output is correct |
5 |
Correct |
112 ms |
1624 KB |
Output is correct |
6 |
Correct |
116 ms |
1624 KB |
Output is correct |
7 |
Correct |
116 ms |
1624 KB |
Output is correct |
8 |
Correct |
112 ms |
1624 KB |
Output is correct |
9 |
Correct |
116 ms |
1624 KB |
Output is correct |
10 |
Correct |
116 ms |
1624 KB |
Output is correct |
11 |
Correct |
112 ms |
1624 KB |
Output is correct |
12 |
Correct |
72 ms |
1624 KB |
Output is correct |
13 |
Correct |
72 ms |
1624 KB |
Output is correct |
14 |
Correct |
72 ms |
1624 KB |
Output is correct |
15 |
Correct |
72 ms |
1624 KB |
Output is correct |
16 |
Correct |
72 ms |
1624 KB |
Output is correct |
17 |
Correct |
72 ms |
1624 KB |
Output is correct |
18 |
Correct |
72 ms |
1624 KB |
Output is correct |
19 |
Correct |
24 ms |
1624 KB |
Output is correct |
20 |
Correct |
24 ms |
1624 KB |
Output is correct |
21 |
Correct |
24 ms |
1624 KB |
Output is correct |
22 |
Correct |
20 ms |
1624 KB |
Output is correct |
23 |
Correct |
24 ms |
1624 KB |
Output is correct |
24 |
Correct |
24 ms |
1624 KB |
Output is correct |
25 |
Correct |
24 ms |
1624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
132 ms |
1624 KB |
Output is correct |
2 |
Correct |
128 ms |
1624 KB |
Output is correct |
3 |
Correct |
96 ms |
1624 KB |
Output is correct |
4 |
Correct |
20 ms |
1624 KB |
Output is correct |
5 |
Correct |
68 ms |
1624 KB |
Output is correct |
6 |
Correct |
28 ms |
1624 KB |
Output is correct |
7 |
Correct |
12 ms |
1624 KB |
Output is correct |
8 |
Correct |
36 ms |
1624 KB |
Output is correct |
9 |
Correct |
8 ms |
1624 KB |
Output is correct |
10 |
Correct |
12 ms |
1624 KB |
Output is correct |
11 |
Correct |
128 ms |
1624 KB |
Output is correct |
12 |
Correct |
128 ms |
1624 KB |
Output is correct |
13 |
Correct |
88 ms |
1624 KB |
Output is correct |
14 |
Correct |
20 ms |
1624 KB |
Output is correct |
15 |
Correct |
64 ms |
1624 KB |
Output is correct |
16 |
Correct |
28 ms |
1624 KB |
Output is correct |
17 |
Correct |
12 ms |
1624 KB |
Output is correct |
18 |
Correct |
36 ms |
1624 KB |
Output is correct |
19 |
Correct |
16 ms |
1624 KB |
Output is correct |
20 |
Correct |
12 ms |
1624 KB |
Output is correct |
21 |
Correct |
120 ms |
1624 KB |
Output is correct |
22 |
Correct |
120 ms |
1624 KB |
Output is correct |
23 |
Correct |
92 ms |
1624 KB |
Output is correct |
24 |
Correct |
20 ms |
1624 KB |
Output is correct |
25 |
Correct |
60 ms |
1624 KB |
Output is correct |
26 |
Correct |
28 ms |
1624 KB |
Output is correct |
27 |
Correct |
8 ms |
1624 KB |
Output is correct |
28 |
Correct |
36 ms |
1624 KB |
Output is correct |
29 |
Correct |
16 ms |
1624 KB |
Output is correct |
30 |
Correct |
12 ms |
1624 KB |
Output is correct |
31 |
Correct |
112 ms |
1624 KB |
Output is correct |
32 |
Correct |
112 ms |
1624 KB |
Output is correct |
33 |
Correct |
84 ms |
1624 KB |
Output is correct |
34 |
Correct |
20 ms |
1624 KB |
Output is correct |
35 |
Correct |
64 ms |
1624 KB |
Output is correct |
36 |
Correct |
24 ms |
1624 KB |
Output is correct |
37 |
Correct |
12 ms |
1624 KB |
Output is correct |
38 |
Correct |
32 ms |
1624 KB |
Output is correct |
39 |
Correct |
12 ms |
1624 KB |
Output is correct |
40 |
Correct |
12 ms |
1624 KB |
Output is correct |