QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#417908#4229. GCD HarmonyfrizzfrizzAC ✓625ms202584kbC++142.5kb2024-05-23 01:34:012024-05-23 01:34:03

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 01:34:03]
  • 评测
  • 测评结果:AC
  • 用时:625ms
  • 内存:202584kb
  • [2024-05-23 01:34:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;

#define A first
#define B second
#define SZ(x) (int)(x.size())

#define FR(i, a, b) for (int i = (a); i < (b); i++)
#define FOR(i, n) FR(i, 0, n)

int N, V, dp[5005][10005], mult[5005][105], val[5005], isNum[10005];
vector<int> adj[5005], nums, isPrime, prs, prDiv[10005];
void calc(int x, int p)
{
    if (SZ(adj[x]) == 1 && adj[x][0] == p)
    {
        FOR(i, SZ(nums))
            dp[x][nums[i]] = nums[i] == val[x] ? 0 : nums[i];
        FOR(i, SZ(prs))
        {
            mult[x][prs[i]] = val[x] % prs[i] == 0 ? 0 : 20000;
            for (int j = prs[i]; j < 10005; j += prs[i])
            {
                if (!isNum[j])
                    continue;
                mult[x][prs[i]] = min(mult[x][prs[i]], dp[x][j]);
            }
        }
        return;
    }
    FOR(i, SZ(adj[x]))
        if (adj[x][i] != p)
            calc(adj[x][i], x);
    FOR(i, SZ(nums))
    {
        dp[x][nums[i]] = val[x] == nums[i] ? 0 : nums[i];
        FOR(j, SZ(adj[x]))
        {
            if (adj[x][j] == p)
                continue;
            int minDp = 20000;
            FOR(k, SZ(prDiv[nums[i]]))
                minDp = min(minDp, mult[adj[x][j]][prDiv[nums[i]][k]]);
            dp[x][nums[i]] += minDp;
        }
    }
    FOR(i, SZ(prs))
    {
        mult[x][prs[i]] = 20000;
        for (int j = prs[i]; j < 10005; j += prs[i])
        {
            if (!isNum[j])
                continue;
            mult[x][prs[i]] = min(mult[x][prs[i]], dp[x][j]);
        }
    }
}

int main()
{
    cin >> N;
    FOR(i, N)
        cin >> val[i];
    FOR(i, N - 1)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    isPrime.resize(100);
    FR(i, 2, 100)
        isPrime[i] = 1;
    FR(i, 2, 100)
    {
        if (isPrime[i])
        {
            for (int j = 2 * i; j < 100; j += i)
                isPrime[j] = 0;
            for (int j = i; j < 10005; j += i)
                prDiv[j].push_back(i);
            prs.push_back(i);
        }
    }
    FR(i, 2, 10005)
    {
        FOR(j, SZ(prs))
        {
            if (i % prs[j] == 0)
            {
                nums.push_back(i);
                isNum[i] = 1;
                break;
            }
        }
    }
    calc(0, 0);
    int ans = 20000;
    FOR(i, SZ(nums))
        ans = min(ans, dp[0][nums[i]]);
    cout << ans;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 6420kb

input:

6
5
6
3
4
9
12
1 2
1 3
1 4
1 6
3 5

output:

6

result:

ok single line: '6'

Test #2:

score: 0
Accepted
time: 2ms
memory: 6480kb

input:

3
1
2
3
3 1
2 3

output:

4

result:

ok single line: '4'

Test #3:

score: 0
Accepted
time: 0ms
memory: 8532kb

input:

13
2
5
5
5
5
5
5
3
3
3
3
3
3
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13

output:

15

result:

ok single line: '15'

Test #4:

score: 0
Accepted
time: 0ms
memory: 8516kb

input:

9
2
5
5
5
5
3
3
3
3
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9

output:

14

result:

ok single line: '14'

Test #5:

score: 0
Accepted
time: 3ms
memory: 8572kb

input:

8
13
13
13
2
13
13
13
13
1 2
1 3
1 4
1 5
1 6
1 7
1 8

output:

13

result:

ok single line: '13'

Test #6:

score: 0
Accepted
time: 533ms
memory: 202160kb

input:

5000
59
25
51
26
33
99
2
13
29
58
5
47
96
83
63
22
69
89
41
90
20
97
85
90
55
17
54
75
54
24
90
54
74
78
81
77
2
47
68
18
60
81
99
86
7
6
76
43
17
43
92
25
36
26
47
100
63
66
2
16
47
25
48
86
24
2
10
42
44
80
92
48
49
21
49
40
32
85
53
88
15
30
4
27
77
16
6
80
50
56
46
14
3
48
92
50
93
35
69
29
48
4...

output:

4778

result:

ok single line: '4778'

Test #7:

score: 0
Accepted
time: 505ms
memory: 202020kb

input:

5000
15
8
34
68
69
24
72
65
85
5
11
7
24
50
94
98
99
88
99
31
58
93
94
14
92
17
45
61
85
83
66
97
35
52
33
41
98
10
77
59
33
23
21
49
83
93
23
77
60
49
27
2
73
10
31
23
8
73
3
94
19
74
78
82
86
95
14
18
58
15
5
58
99
60
82
34
82
6
96
31
70
6
8
49
82
51
95
52
95
55
94
21
74
83
19
7
99
74
49
65
25
6
5...

output:

4733

result:

ok single line: '4733'

Test #8:

score: 0
Accepted
time: 528ms
memory: 202188kb

input:

5000
15
15
14
18
19
15
13
18
16
17
16
18
16
16
17
16
19
17
16
19
15
13
17
15
15
14
15
16
16
14
18
15
19
16
18
15
14
13
15
15
13
19
18
15
17
14
15
14
17
16
13
13
19
16
18
19
14
19
17
13
19
14
15
14
15
13
13
17
18
15
17
17
16
16
18
19
19
16
13
16
18
15
15
17
16
15
14
16
13
18
13
18
19
18
15
13
13
14
1...

output:

5609

result:

ok single line: '5609'

Test #9:

score: 0
Accepted
time: 515ms
memory: 202008kb

input:

5000
97
96
97
94
96
94
95
95
95
93
95
94
96
96
95
94
93
95
95
97
95
96
94
97
97
97
94
95
93
96
94
94
96
93
93
93
97
94
96
95
94
94
94
97
94
96
93
97
95
97
93
96
93
93
95
97
96
93
94
97
95
94
94
95
96
97
93
94
97
96
97
93
93
93
97
94
94
95
95
95
94
96
95
93
96
97
97
95
94
93
97
93
97
96
94
94
93
93
9...

output:

5497

result:

ok single line: '5497'

Test #10:

score: 0
Accepted
time: 514ms
memory: 202132kb

input:

5000
79
71
73
97
79
61
61
97
67
61
89
73
67
79
83
97
61
61
61
83
97
83
71
79
97
97
97
71
89
71
83
61
73
89
73
73
73
67
61
97
71
73
89
71
83
67
71
67
73
73
97
79
67
79
89
73
97
97
73
67
61
71
73
83
67
73
71
61
79
61
73
73
89
79
71
89
83
67
71
97
67
71
89
83
71
61
79
89
79
97
83
89
83
79
71
79
89
61
6...

output:

10000

result:

ok single line: '10000'

Test #11:

score: 0
Accepted
time: 519ms
memory: 202092kb

input:

5000
73
83
73
97
97
73
97
83
83
83
73
83
73
97
97
73
83
73
83
97
97
83
97
73
97
83
97
73
97
73
97
97
83
97
97
83
73
83
97
83
83
73
83
97
73
73
97
83
83
83
97
73
97
97
83
83
97
73
73
97
73
73
97
83
83
97
73
97
83
83
73
97
73
97
73
73
73
73
97
83
97
83
97
73
83
97
83
83
73
73
83
73
83
97
83
83
97
97
8...

output:

10000

result:

ok single line: '10000'

Test #12:

score: 0
Accepted
time: 509ms
memory: 202152kb

input:

5000
5
5
7
2
2
3
2
7
2
5
5
3
7
7
3
3
7
5
3
3
3
5
2
7
5
2
2
2
3
7
3
5
3
2
3
7
2
2
5
3
7
2
3
7
3
2
7
3
2
5
3
3
5
2
7
5
3
3
5
5
5
5
2
3
2
7
7
2
5
3
3
2
5
7
5
5
7
5
3
5
7
2
7
7
2
7
5
7
5
2
5
7
2
7
2
5
7
2
7
7
5
5
7
7
5
5
3
3
3
7
3
5
7
7
7
7
3
5
3
3
7
5
3
3
2
5
5
3
3
2
7
2
5
7
2
3
2
7
5
7
7
2
7
5
2
3
2
7...

output:

7404

result:

ok single line: '7404'

Test #13:

score: 0
Accepted
time: 451ms
memory: 202092kb

input:

5000
71
71
71
71
73
71
71
73
73
71
73
73
73
73
73
73
73
73
71
73
71
71
73
73
71
71
73
71
71
71
73
71
71
71
73
73
73
73
71
71
73
71
71
71
71
71
71
73
71
71
71
71
71
73
71
71
71
71
71
73
71
73
73
73
73
73
73
71
71
73
73
71
73
71
71
71
71
71
71
73
73
73
73
71
71
73
73
73
73
71
71
71
73
71
71
71
71
71
7...

output:

10000

result:

ok single line: '10000'

Test #14:

score: 0
Accepted
time: 343ms
memory: 202164kb

input:

5000
3
5
5
3
5
2
5
3
2
3
5
5
2
5
2
2
2
3
2
5
5
3
3
5
2
2
3
5
2
2
3
3
2
2
2
3
5
5
2
5
2
5
2
3
5
3
3
5
2
3
5
3
3
5
5
5
5
3
3
5
3
2
2
2
3
3
3
5
3
2
5
2
3
2
5
3
2
2
3
2
3
2
5
5
2
2
5
3
2
2
3
5
3
3
2
2
3
5
2
2
3
2
5
3
2
3
3
2
5
5
3
5
5
5
5
3
3
5
3
5
5
3
2
3
5
5
3
3
3
2
3
3
5
3
3
3
2
2
2
3
3
5
2
3
3
3
2
5...

output:

2126

result:

ok single line: '2126'

Test #15:

score: 0
Accepted
time: 351ms
memory: 202116kb

input:

5000
26
17
19
19
11
19
17
11
26
17
19
17
26
19
11
19
17
11
26
26
11
26
11
11
19
11
17
17
26
19
17
11
26
17
17
11
17
19
11
17
11
26
11
17
11
26
19
17
11
17
19
26
11
19
26
26
17
11
19
17
11
17
17
17
11
26
26
17
19
11
11
19
17
26
19
19
17
19
11
17
11
11
19
17
11
11
11
26
11
17
19
17
26
11
26
17
19
11
1...

output:

5268

result:

ok single line: '5268'

Test #16:

score: 0
Accepted
time: 490ms
memory: 201992kb

input:

5000
13
11
13
11
13
11
11
11
11
13
13
11
11
11
11
11
13
11
11
11
11
13
11
11
11
13
13
11
11
13
13
13
11
13
13
13
11
11
11
13
13
11
11
13
13
11
11
13
11
13
13
11
13
11
13
13
13
13
13
13
11
13
13
11
11
13
11
11
13
11
13
11
11
11
13
13
13
13
13
13
11
11
13
11
11
11
13
11
13
11
11
13
11
13
11
11
13
13
1...

output:

10000

result:

ok single line: '10000'

Test #17:

score: 0
Accepted
time: 428ms
memory: 202080kb

input:

5000
3
2
5
5
2
2
5
2
2
3
2
3
2
2
2
5
5
5
2
2
5
2
5
2
3
3
3
2
3
2
5
2
3
2
5
2
3
2
5
2
5
3
5
5
5
3
2
5
5
3
2
2
3
5
3
5
2
2
2
2
5
5
5
2
5
2
2
5
2
2
3
2
3
2
2
5
2
5
2
3
3
3
5
5
3
5
3
2
5
5
3
3
2
3
2
2
2
3
2
3
2
3
2
2
2
5
2
5
5
2
2
3
3
2
3
2
2
5
2
2
3
5
3
3
5
2
2
5
5
3
2
3
3
3
3
5
3
3
5
3
5
2
3
2
3
2
3
2...

output:

6330

result:

ok single line: '6330'

Test #18:

score: 0
Accepted
time: 369ms
memory: 202096kb

input:

5000
6
14
35
14
14
6
14
14
14
6
15
15
10
21
15
6
21
6
6
35
21
21
6
15
35
15
10
14
35
10
15
10
35
6
15
10
14
14
21
15
10
15
14
6
10
21
35
21
21
21
10
21
35
6
35
15
6
35
10
14
15
6
35
14
35
21
35
6
14
10
21
15
10
21
6
14
35
35
15
6
6
10
35
15
21
21
35
10
15
10
14
35
21
21
21
6
6
35
15
21
21
14
14
21
3...

output:

1666

result:

ok single line: '1666'

Test #19:

score: 0
Accepted
time: 344ms
memory: 202096kb

input:

5000
21
15
6
10
6
14
6
14
10
15
10
14
10
15
35
15
14
14
6
6
10
35
21
14
10
35
10
15
10
6
15
14
15
10
21
21
21
15
35
21
21
6
15
21
6
35
10
10
10
15
10
15
15
10
21
15
35
10
6
15
21
35
15
35
15
35
14
15
10
6
35
10
14
10
14
6
21
10
21
35
10
35
21
14
10
15
10
6
10
35
6
14
6
35
15
21
14
15
35
21
10
35
21
...

output:

510

result:

ok single line: '510'

Test #20:

score: 0
Accepted
time: 622ms
memory: 202488kb

input:

5000
5
1
1
1
1
5
1
3
1
1
3
1
1
1
3
3
1
1
1
1
3
1
3
1
1
1
5
3
5
1
3
1
1
1
3
3
1
1
5
1
1
1
5
5
3
5
1
1
1
1
5
1
1
1
5
5
1
1
1
1
1
3
3
1
5
1
5
1
1
3
3
1
1
3
1
3
1
1
1
1
1
1
1
3
1
5
3
3
3
1
3
1
1
5
1
1
1
1
3
3
3
5
5
5
5
3
1
5
5
5
1
3
1
1
1
1
1
5
3
1
3
1
3
3
1
3
3
1
1
5
3
3
3
3
3
5
1
1
1
3
1
1
5
1
1
5
3
1...

output:

9450

result:

ok single line: '9450'

Test #21:

score: 0
Accepted
time: 625ms
memory: 202352kb

input:

5000
6
6
10
6
10
6
10
21
10
6
15
21
35
10
14
10
15
10
10
15
6
14
15
35
14
14
15
6
35
10
35
10
14
21
21
21
15
21
14
6
21
10
15
14
35
15
35
21
35
14
6
35
10
15
35
21
35
10
14
35
14
35
21
21
10
15
10
14
35
15
35
35
6
35
14
21
35
14
14
21
21
15
14
14
21
15
10
15
6
6
10
35
14
35
14
21
6
14
14
10
35
6
6
2...

output:

1965

result:

ok single line: '1965'

Test #22:

score: 0
Accepted
time: 570ms
memory: 202320kb

input:

4999
100
94
98
90
94
86
90
86
81
94
80
80
98
89
90
92
97
93
91
89
94
85
92
82
84
82
93
80
99
92
91
84
98
90
95
86
94
89
82
85
84
97
83
98
94
94
83
100
91
97
84
95
94
93
93
90
84
90
96
82
89
97
83
85
83
95
82
90
92
90
83
85
100
93
84
86
86
94
89
94
88
100
88
97
89
98
96
95
95
97
85
95
87
95
84
99
80
...

output:

4469

result:

ok single line: '4469'

Test #23:

score: 0
Accepted
time: 574ms
memory: 202120kb

input:

4999
75
75
62
65
78
63
61
62
68
68
72
69
79
63
77
74
79
78
79
70
75
68
69
78
80
63
68
76
70
62
63
67
69
80
78
71
71
77
76
67
62
74
69
67
69
67
62
78
67
62
71
65
64
68
76
61
76
80
67
63
70
62
64
67
63
65
65
64
71
77
68
66
60
63
73
72
75
77
64
76
63
78
68
80
63
78
68
71
65
80
70
66
73
75
62
67
75
67
7...

output:

4476

result:

ok single line: '4476'

Test #24:

score: 0
Accepted
time: 585ms
memory: 202080kb

input:

4999
44
47
46
52
56
42
41
59
43
54
52
54
44
50
59
46
48
52
56
53
44
46
43
42
50
42
47
47
49
56
58
41
52
49
44
53
47
49
47
50
44
48
41
44
54
57
50
54
59
42
60
51
42
52
57
40
51
47
59
49
50
57
60
52
60
42
41
51
40
58
47
52
41
41
42
59
55
52
51
41
44
52
43
40
54
42
40
53
49
51
46
58
50
46
47
52
44
47
4...

output:

4641

result:

ok single line: '4641'

Test #25:

score: 0
Accepted
time: 585ms
memory: 202100kb

input:

4999
29
32
28
31
33
21
26
21
40
29
21
28
23
26
21
31
32
31
22
30
35
38
24
31
35
25
35
40
25
22
37
40
22
36
39
33
28
37
23
32
27
28
27
20
29
38
40
40
31
20
31
30
22
34
20
26
39
26
28
39
35
36
31
40
25
21
39
23
24
29
35
35
31
24
29
40
23
27
26
21
27
37
25
25
35
40
32
33
26
30
28
37
29
28
24
20
34
21
3...

output:

4617

result:

ok single line: '4617'

Test #26:

score: 0
Accepted
time: 518ms
memory: 202012kb

input:

5000
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7
7...

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 532ms
memory: 202136kb

input:

5000
55
35
77
35
35
35
77
35
35
55
77
35
77
77
35
77
55
35
77
35
77
55
55
35
77
77
77
35
55
55
35
77
35
55
55
55
55
77
55
35
77
77
35
35
77
35
55
35
35
55
77
35
55
35
35
55
55
55
35
55
55
35
35
77
55
35
55
77
55
35
55
55
55
77
77
77
35
35
77
35
35
35
35
35
77
55
35
35
55
55
35
77
55
35
55
35
77
55
3...

output:

0

result:

ok single line: '0'

Test #28:

score: 0
Accepted
time: 514ms
memory: 202040kb

input:

5000
24
24
9
6
6
12
72
6
12
18
9
12
9
18
12
18
6
9
12
12
18
12
18
6
24
9
6
9
72
12
12
6
12
24
24
24
72
9
18
9
72
12
9
18
6
9
24
18
18
72
24
6
12
72
18
6
18
9
9
9
6
18
6
24
12
9
18
24
24
6
6
72
18
12
24
24
9
72
6
6
18
24
6
6
6
18
12
24
24
18
12
9
6
9
72
18
12
72
9
72
6
6
6
9
72
18
24
6
24
12
6
18
18
...

output:

0

result:

ok single line: '0'

Test #29:

score: 0
Accepted
time: 511ms
memory: 202032kb

input:

4999
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1...

output:

9998

result:

ok single line: '9998'

Test #30:

score: 0
Accepted
time: 591ms
memory: 202584kb

input:

5000
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
89
8...

output:

372

result:

ok single line: '372'

Test #31:

score: 0
Accepted
time: 2ms
memory: 6472kb

input:

2
45
20
2 1

output:

0

result:

ok single line: '0'

Test #32:

score: 0
Accepted
time: 2ms
memory: 6476kb

input:

8
5
3
3
3
3
2
2
2
1 2
1 3
1 4
1 5
1 6
1 7
1 8

output:

6

result:

ok single line: '6'

Test #33:

score: 0
Accepted
time: 2ms
memory: 6408kb

input:

8
5
4
4
4
4
8
8
8
1 2
1 3
1 4
1 5
1 6
1 7
1 8

output:

2

result:

ok single line: '2'

Test #34:

score: 0
Accepted
time: 416ms
memory: 202020kb

input:

5000
1
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53
53...

output:

5141

result:

ok single line: '5141'

Test #35:

score: 0
Accepted
time: 405ms
memory: 202028kb

input:

5000
97
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
2
3
5
7
11
13
...

output:

3542

result:

ok single line: '3542'

Test #36:

score: 0
Accepted
time: 403ms
memory: 202032kb

input:

5000
97
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
23
3
11
13
...

output:

3358

result:

ok single line: '3358'

Test #37:

score: 0
Accepted
time: 402ms
memory: 202168kb

input:

5000
1
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
79
83
89
97
7
73
7...

output:

7686

result:

ok single line: '7686'

Test #38:

score: 0
Accepted
time: 413ms
memory: 202088kb

input:

5000
1
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53
59
61
67
71
73
79
83
89
97
43
47
53...

output:

9252

result:

ok single line: '9252'

Test #39:

score: 0
Accepted
time: 409ms
memory: 202092kb

input:

5000
1
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
5
7
11
13
17
19
23
29
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
5
7
11
13
17
19
23
29
31
37...

output:

9198

result:

ok single line: '9198'

Test #40:

score: 0
Accepted
time: 410ms
memory: 202028kb

input:

5000
1
11
13
17
19
23
29
30
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
7
11
13
17
19
23
29
30
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
7
11
13
17
19
23
29
30
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
7
11
13
17
19
23
29
30
31
37
41
43
47
53
59
61
67
71
73
79
83
89
97
7
11
13
17
19
23
29
30
...

output:

8846

result:

ok single line: '8846'