Submission #13915

# Submission time Handle Problem Language Result Execution time Memory
13915 2015-04-22T10:34:04 Z gs14004 경비원 (GA8_guard) C++14
100 / 100
419 ms 1492 KB
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int mod = 1e9 + 7;

int n;
int pr[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};

struct num{
    int val;
    int lowbit;
    int rem;
}a[2223];

bool cmp(num a, num b){return a.rem < b.rem;}

void input(){
    scanf("%d",&n);
    for (int i=1; i<=n; i++) {
        scanf("%d",&a[i].val);
        int t = a[i].val;
        for (int j=0; j<15; j++) {
            while(t % pr[j] == 0){
                a[i].lowbit |= 1<<j;
                t /= pr[j];
            }
        }
        a[i].rem = t;
    }
    sort(a+1,a+n+1,cmp);
}

int dp[2][1<<15];
int back[1<<15];

int main(){
    input();
    dp[0][0] = 1;
    for (int i=1; i<=n; i++) {
        if(a[i].rem == 1){
            for (int j=0; j<(1<<15); j++) {
                dp[i%2][j] = 0;
                if((a[i].lowbit & ~j) == 0){
                    dp[i%2][j] = dp[(i-1)%2][j ^ a[i].lowbit];
                }
                dp[i%2][j] += dp[(i-1)%2][j];
                dp[i%2][j] %= mod;
            }
        }
        else{
            if(a[i].rem != a[i-1].rem){
                memcpy(back,dp[(i-1)%2],sizeof(back));
            }
            for (int j=0; j<(1<<15); j++) {
                dp[i%2][j] = 0;
                if((a[i].lowbit & ~j) == 0){
                    dp[i%2][j] = back[j ^ a[i].lowbit];
                }
                dp[i%2][j] += dp[(i-1)%2][j];
                dp[i%2][j] %= mod;
            }
        }
    }
    int ret = mod - n - 1;
    for (int i=0; i<(1<<15); i++) {
        ret += dp[n%2][i];
        ret %= mod;
    }
    printf("%d",ret);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1492 KB Output is correct
2 Correct 0 ms 1492 KB Output is correct
3 Correct 0 ms 1492 KB Output is correct
4 Correct 1 ms 1492 KB Output is correct
5 Correct 2 ms 1492 KB Output is correct
6 Correct 0 ms 1492 KB Output is correct
7 Correct 0 ms 1492 KB Output is correct
8 Correct 2 ms 1492 KB Output is correct
9 Correct 3 ms 1492 KB Output is correct
10 Correct 3 ms 1492 KB Output is correct
11 Correct 4 ms 1492 KB Output is correct
12 Correct 0 ms 1492 KB Output is correct
13 Correct 0 ms 1492 KB Output is correct
14 Correct 1 ms 1492 KB Output is correct
15 Correct 0 ms 1492 KB Output is correct
16 Correct 0 ms 1492 KB Output is correct
17 Correct 1 ms 1492 KB Output is correct
18 Correct 0 ms 1492 KB Output is correct
19 Correct 0 ms 1492 KB Output is correct
20 Correct 0 ms 1492 KB Output is correct
21 Correct 0 ms 1492 KB Output is correct
22 Correct 2 ms 1492 KB Output is correct
23 Correct 2 ms 1492 KB Output is correct
24 Correct 3 ms 1492 KB Output is correct
25 Correct 3 ms 1492 KB Output is correct
26 Correct 3 ms 1492 KB Output is correct
27 Correct 0 ms 1492 KB Output is correct
28 Correct 4 ms 1492 KB Output is correct
29 Correct 4 ms 1492 KB Output is correct
30 Correct 5 ms 1492 KB Output is correct
31 Correct 1 ms 1492 KB Output is correct
32 Correct 1 ms 1492 KB Output is correct
33 Correct 0 ms 1492 KB Output is correct
34 Correct 0 ms 1492 KB Output is correct
35 Correct 0 ms 1492 KB Output is correct
36 Correct 4 ms 1492 KB Output is correct
37 Correct 0 ms 1492 KB Output is correct
38 Correct 0 ms 1492 KB Output is correct
39 Correct 2 ms 1492 KB Output is correct
40 Correct 0 ms 1492 KB Output is correct
41 Correct 3 ms 1492 KB Output is correct
42 Correct 4 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1492 KB Output is correct
2 Correct 0 ms 1492 KB Output is correct
3 Correct 1 ms 1492 KB Output is correct
4 Correct 0 ms 1492 KB Output is correct
5 Correct 0 ms 1492 KB Output is correct
6 Correct 0 ms 1492 KB Output is correct
7 Correct 2 ms 1492 KB Output is correct
8 Correct 0 ms 1492 KB Output is correct
9 Correct 0 ms 1492 KB Output is correct
10 Correct 0 ms 1492 KB Output is correct
11 Correct 2 ms 1492 KB Output is correct
12 Correct 3 ms 1492 KB Output is correct
13 Correct 0 ms 1492 KB Output is correct
14 Correct 0 ms 1492 KB Output is correct
15 Correct 0 ms 1492 KB Output is correct
16 Correct 0 ms 1492 KB Output is correct
17 Correct 3 ms 1492 KB Output is correct
18 Correct 3 ms 1492 KB Output is correct
19 Correct 4 ms 1492 KB Output is correct
20 Correct 4 ms 1492 KB Output is correct
21 Correct 4 ms 1492 KB Output is correct
22 Correct 4 ms 1492 KB Output is correct
23 Correct 4 ms 1492 KB Output is correct
24 Correct 4 ms 1492 KB Output is correct
25 Correct 5 ms 1492 KB Output is correct
26 Correct 5 ms 1492 KB Output is correct
27 Correct 5 ms 1492 KB Output is correct
28 Correct 5 ms 1492 KB Output is correct
29 Correct 5 ms 1492 KB Output is correct
30 Correct 5 ms 1492 KB Output is correct
31 Correct 6 ms 1492 KB Output is correct
32 Correct 6 ms 1492 KB Output is correct
33 Correct 6 ms 1492 KB Output is correct
34 Correct 6 ms 1492 KB Output is correct
35 Correct 6 ms 1492 KB Output is correct
36 Correct 3 ms 1492 KB Output is correct
37 Correct 7 ms 1492 KB Output is correct
38 Correct 3 ms 1492 KB Output is correct
39 Correct 7 ms 1492 KB Output is correct
40 Correct 7 ms 1492 KB Output is correct
41 Correct 7 ms 1492 KB Output is correct
42 Correct 7 ms 1492 KB Output is correct
43 Correct 3 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 340 ms 1492 KB Output is correct
2 Correct 340 ms 1492 KB Output is correct
3 Correct 419 ms 1492 KB Output is correct
4 Correct 336 ms 1492 KB Output is correct
5 Correct 374 ms 1492 KB Output is correct
6 Correct 389 ms 1492 KB Output is correct
7 Correct 335 ms 1492 KB Output is correct
8 Correct 329 ms 1492 KB Output is correct
9 Correct 345 ms 1492 KB Output is correct
10 Correct 348 ms 1492 KB Output is correct
11 Correct 362 ms 1492 KB Output is correct
12 Correct 320 ms 1492 KB Output is correct
13 Correct 359 ms 1492 KB Output is correct
14 Correct 345 ms 1492 KB Output is correct
15 Correct 320 ms 1492 KB Output is correct
16 Correct 313 ms 1492 KB Output is correct
17 Correct 317 ms 1492 KB Output is correct
18 Correct 297 ms 1492 KB Output is correct
19 Correct 326 ms 1492 KB Output is correct
20 Correct 292 ms 1492 KB Output is correct
21 Correct 326 ms 1492 KB Output is correct
22 Correct 314 ms 1492 KB Output is correct
23 Correct 289 ms 1492 KB Output is correct
24 Correct 286 ms 1492 KB Output is correct
25 Correct 253 ms 1492 KB Output is correct
26 Correct 250 ms 1492 KB Output is correct
27 Correct 276 ms 1492 KB Output is correct
28 Correct 248 ms 1492 KB Output is correct
29 Correct 278 ms 1492 KB Output is correct
30 Correct 272 ms 1492 KB Output is correct
31 Correct 249 ms 1492 KB Output is correct
32 Correct 245 ms 1492 KB Output is correct
33 Correct 198 ms 1492 KB Output is correct
34 Correct 224 ms 1492 KB Output is correct
35 Correct 213 ms 1492 KB Output is correct
36 Correct 193 ms 1492 KB Output is correct
37 Correct 215 ms 1492 KB Output is correct
38 Correct 210 ms 1492 KB Output is correct
39 Correct 193 ms 1492 KB Output is correct
40 Correct 192 ms 1492 KB Output is correct
41 Correct 336 ms 1492 KB Output is correct
42 Correct 334 ms 1492 KB Output is correct
43 Correct 345 ms 1492 KB Output is correct
44 Correct 337 ms 1492 KB Output is correct
45 Correct 341 ms 1492 KB Output is correct
46 Correct 336 ms 1492 KB Output is correct
47 Correct 345 ms 1492 KB Output is correct
48 Correct 341 ms 1492 KB Output is correct
49 Correct 347 ms 1492 KB Output is correct
50 Correct 342 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 370 ms 1492 KB Output is correct
2 Correct 329 ms 1492 KB Output is correct
3 Correct 297 ms 1492 KB Output is correct
4 Correct 267 ms 1492 KB Output is correct
5 Correct 191 ms 1492 KB Output is correct
6 Correct 187 ms 1492 KB Output is correct
7 Correct 190 ms 1492 KB Output is correct
8 Correct 190 ms 1492 KB Output is correct
9 Correct 186 ms 1492 KB Output is correct
10 Correct 190 ms 1492 KB Output is correct
11 Correct 190 ms 1492 KB Output is correct
12 Correct 113 ms 1492 KB Output is correct
13 Correct 115 ms 1492 KB Output is correct
14 Correct 109 ms 1492 KB Output is correct
15 Correct 114 ms 1492 KB Output is correct
16 Correct 110 ms 1492 KB Output is correct
17 Correct 114 ms 1492 KB Output is correct
18 Correct 128 ms 1492 KB Output is correct
19 Correct 23 ms 1492 KB Output is correct
20 Correct 27 ms 1492 KB Output is correct
21 Correct 28 ms 1492 KB Output is correct
22 Correct 26 ms 1492 KB Output is correct
23 Correct 26 ms 1492 KB Output is correct
24 Correct 26 ms 1492 KB Output is correct
25 Correct 26 ms 1492 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 343 ms 1492 KB Output is correct
2 Correct 369 ms 1492 KB Output is correct
3 Correct 346 ms 1492 KB Output is correct
4 Correct 338 ms 1492 KB Output is correct
5 Correct 330 ms 1492 KB Output is correct
6 Correct 354 ms 1492 KB Output is correct
7 Correct 342 ms 1492 KB Output is correct
8 Correct 325 ms 1492 KB Output is correct
9 Correct 321 ms 1492 KB Output is correct
10 Correct 351 ms 1492 KB Output is correct
11 Correct 328 ms 1492 KB Output is correct
12 Correct 350 ms 1492 KB Output is correct
13 Correct 328 ms 1492 KB Output is correct
14 Correct 323 ms 1492 KB Output is correct
15 Correct 320 ms 1492 KB Output is correct
16 Correct 315 ms 1492 KB Output is correct
17 Correct 335 ms 1492 KB Output is correct
18 Correct 306 ms 1492 KB Output is correct
19 Correct 306 ms 1492 KB Output is correct
20 Correct 335 ms 1492 KB Output is correct
21 Correct 300 ms 1492 KB Output is correct
22 Correct 300 ms 1492 KB Output is correct
23 Correct 301 ms 1492 KB Output is correct
24 Correct 317 ms 1492 KB Output is correct
25 Correct 292 ms 1492 KB Output is correct
26 Correct 290 ms 1492 KB Output is correct
27 Correct 299 ms 1492 KB Output is correct
28 Correct 278 ms 1492 KB Output is correct
29 Correct 280 ms 1492 KB Output is correct
30 Correct 304 ms 1492 KB Output is correct
31 Correct 276 ms 1492 KB Output is correct
32 Correct 258 ms 1492 KB Output is correct
33 Correct 256 ms 1492 KB Output is correct
34 Correct 271 ms 1492 KB Output is correct
35 Correct 251 ms 1492 KB Output is correct
36 Correct 249 ms 1492 KB Output is correct
37 Correct 255 ms 1492 KB Output is correct
38 Correct 244 ms 1492 KB Output is correct
39 Correct 239 ms 1492 KB Output is correct
40 Correct 263 ms 1492 KB Output is correct