QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#87488#21. GCD-sumChinese_zjc_5 14ms3484kbC++141.0kb2023-03-13 11:24:362023-03-13 11:24:39

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-13 11:24:39]
  • 评测
  • 测评结果:5
  • 用时:14ms
  • 内存:3484kb
  • [2023-03-13 11:24:36]
  • 提交

answer

// This Code was made by Chinese_zjc_.
#include <bits/stdc++.h>
// #define debug
int n;
long long ans[500005];
std::vector<long long> a;
signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin >> n;
    a.resize(n);
    for (int i = 0; i != n; ++i)
        std::cin >> a[i];
    ans[a.size()] = std::accumulate(a.begin(), a.end(), 0ll);
    while (a.size() >= 2)
    {
        std::pair<int, int> x;
        long long min = LLONG_MAX;
        for (std::size_t i = 0; i != a.size(); ++i)
            for (std::size_t j = i + 1; j != a.size(); ++j)
                if (a[i] + a[j] - std::__gcd(a[i], a[j]) <= min)
                    x = {i, j}, min = a[i] + a[j] - std::__gcd(a[i], a[j]);
        long long nxt = std::__gcd(a[x.first], a[x.second]);
        a.erase(a.begin() + x.second);
        a.erase(a.begin() + x.first);
        a.push_back(nxt);
        ans[a.size()] = std::accumulate(a.begin(), a.end(), 0ll);
    }
    for (int i = 1; i <= n; ++i)
        std::cout << ans[i] << '\n';
    return 0;
}

詳細信息

Subtask #1:

score: 5
Accepted

Test #1:

score: 5
Accepted
time: 2ms
memory: 3364kb

input:

7
18 30 10 23 1 3 13

output:

1
31
54
72
85
95
98

result:

ok 7 lines

Test #2:

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

input:

7
11 12 12 15 30 6 10

output:

1
31
46
58
72
84
96

result:

ok 7 lines

Test #3:

score: 0
Accepted
time: 1ms
memory: 3392kb

input:

7
14 19 17 12 5 24 3

output:

1
25
44
61
75
87
94

result:

ok 7 lines

Test #4:

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

input:

7
13 15 19 21 27 28 30

output:

1
31
59
86
107
126
153

result:

ok 7 lines

Test #5:

score: 0
Accepted
time: 1ms
memory: 3372kb

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Test #6:

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

input:

7
21 6 17 20 5 22 27

output:

1
28
50
71
91
108
118

result:

ok 7 lines

Test #7:

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

input:

7
11 17 16 30 24 21 23

output:

1
31
55
78
99
116
142

result:

ok 7 lines

Test #8:

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

input:

7
13 20 16 4 29 26 5

output:

1
30
56
76
92
105
113

result:

ok 7 lines

Test #9:

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

input:

7
25 17 12 16 13 30 30

output:

1
31
61
86
103
119
143

result:

ok 7 lines

Test #10:

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

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Test #11:

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

input:

7
25 6 29 7 22 14 30

output:

1
31
60
85
107
121
133

result:

ok 7 lines

Test #12:

score: 0
Accepted
time: 1ms
memory: 3484kb

input:

7
21 24 20 30 2 5 21

output:

1
31
55
76
97
117
123

result:

ok 7 lines

Test #13:

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

input:

7
21 19 26 1 28 7 27

output:

1
29
56
82
103
122
129

result:

ok 7 lines

Test #14:

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

input:

7
26 11 28 24 30 23 24

output:

1
31
59
85
109
142
166

result:

ok 7 lines

Test #15:

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

input:

7
4 8 12 13 13 13 24

output:

1
25
41
54
67
79
87

result:

ok 7 lines

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #16:

score: 5
Accepted
time: 1ms
memory: 3324kb

input:

15
11 28 29 11 13 18 23 1 5 20 24 20 23 3 2

output:

1
30
58
82
105
128
148
168
186
199
210
221
226
229
231

result:

ok 15 lines

Test #17:

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

input:

15
9 11 16 26 18 17 11 15 23 2 30 30 30 9 18

output:

1
31
61
91
117
140
158
176
193
209
224
235
246
256
265

result:

ok 15 lines

Test #18:

score: 0
Accepted
time: 1ms
memory: 3432kb

input:

15
22 9 18 3 14 18 4 17 26 26 12 26 8 6 15

output:

1
27
53
79
101
119
137
154
169
183
195
204
212
218
224

result:

ok 15 lines

Test #19:

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

input:

15
27 11 25 28 21 28 19 29 23 16 21 10 17 29 16

output:

1
30
59
87
115
142
167
190
211
232
251
268
284
304
320

result:

ok 15 lines

Test #20:

score: 0
Accepted
time: 1ms
memory: 3328kb

input:

15
2 4 6 8 10 12 14 15 15 15 15 15 15 15 28

output:

1
29
45
60
75
90
105
120
135
149
161
171
179
185
189

result:

ok 15 lines

Test #21:

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

input:

15
28 23 26 12 15 9 9 30 23 16 10 10 9 22 4

output:

1
31
59
85
108
131
153
169
184
196
206
218
228
237
246

result:

ok 15 lines

Test #22:

score: -5
Wrong Answer
time: 2ms
memory: 3360kb

input:

15
4 7 17 3 24 30 22 5 26 11 15 3 6 25 21

output:

1
31
57
82
106
128
149
166
181
192
199
204
210
216
219

result:

wrong answer 12th lines differ - expected: '205', found: '204'

Subtask #3:

score: 0
Wrong Answer

Test #31:

score: 8
Accepted
time: 11ms
memory: 3356kb

input:

100
268 467 21 173 158 287 36 446 36 340 311 283 58 77 464 119 460 198 405 331 214 331 255 157 418 319 354 289 330 64 11 484 186 129 130 368 370 468 292 180 427 76 87 156 13 379 268 170 3 15 263 52 296 242 7 296 376 148 221 270 218 131 326 198 399 132 270 55 299 444 134 222 278 486 409 72 38 193 359...

output:

1
497
990
1476
1960
2428
2895
3359
3819
4274
4720
5164
5591
6009
6420
6829
7234
7633
8028
8422
8801
9177
9547
9915
10277
10636
10990
11335
11675
12006
12337
12667
12993
13312
13623
13934
14244
14543
14839
15135
15427
15716
16003
16286
16564
16838
17108
17378
17646
17914
18181
18444
18699
18941
19166...

result:

ok 100 lines

Test #32:

score: 0
Accepted
time: 11ms
memory: 3464kb

input:

100
481 171 450 127 152 475 484 86 266 265 354 457 493 439 102 277 387 150 217 412 84 103 78 446 66 133 369 373 193 244 339 173 288 171 330 21 471 473 228 131 139 102 408 59 10 25 472 382 422 375 448 72 242 453 196 337 287 389 497 154 243 77 50 211 216 408 450 370 353 213 154 463 13 459 154 154 201 ...

output:

1
498
991
1475
1957
2438
2913
3386
3858
4329
4798
5261
5720
6177
6630
7080
7530
7978
8424
8863
9299
9733
10158
10582
11004
11416
11824
12232
12621
13008
13390
13765
14138
14508
14877
15231
15584
15923
16260
16590
16917
17219
17513
17807
18095
18382
18659
18936
19208
19474
19739
19984
20228
20471
207...

result:

ok 100 lines

Test #33:

score: 0
Accepted
time: 14ms
memory: 3376kb

input:

100
187 294 383 120 383 131 140 370 192 54 467 391 314 398 147 27 492 72 409 145 346 34 234 342 58 61 174 358 225 27 446 476 111 116 364 40 195 82 392 262 493 486 478 240 234 81 177 150 221 351 200 52 354 123 189 115 340 189 22 353 486 368 241 138 174 276 322 379 404 288 145 350 472 254 286 432 152 ...

output:

1
494
986
1478
1964
2450
2931
3409
3885
4357
4827
5294
5749
6200
6646
7078
7488
7897
8301
8699
9091
9482
9868
10251
10634
11013
11391
11761
12129
12493
12851
13205
13558
13909
14259
14605
14947
15287
15614
15938
16260
16581
16895
17197
17491
17779
18065
18341
18613
18885
19147
19401
19642
19882
2011...

result:

ok 100 lines

Test #34:

score: -8
Wrong Answer
time: 6ms
memory: 3384kb

input:

100
496 500 483 488 491 494 483 497 483 484 489 489 481 498 481 480 482 496 484 485 492 486 482 492 496 499 484 489 485 500 480 481 486 489 499 493 499 485 499 491 480 498 490 484 495 490 488 489 487 487 491 488 487 485 497 493 497 487 488 496 487 490 482 487 489 483 499 488 491 491 483 480 491 485 ...

output:

1
500
998
1495
1991
2486
2980
3473
3965
4456
4945
5433
5920
6406
6890
7373
7855
8340
8830
9330
10290
10790
11290
11789
12288
12787
13286
13784
14282
14780
15277
15774
16271
16768
17264
17760
18256
18751
19245
19739
20232
20725
21218
21710
22202
22694
23185
23676
24167
24658
25149
25640
26130
26620
2...

result:

wrong answer 2nd lines differ - expected: '501', found: '500'

Subtask #4:

score: 0
Time Limit Exceeded

Test #51:

score: 0
Time Limit Exceeded

input:

1270
1 2 6 7 8 9 10 11 13 14 16 18 19 20 22 23 25 26 28 30 31 32 33 37 38 40 42 43 44 45 46 47 48 49 50 52 53 55 56 57 58 59 62 63 64 67 68 69 70 71 72 74 75 77 78 80 85 86 87 88 89 90 92 96 97 98 99 100 101 103 104 105 107 108 109 113 119 122 124 126 128 132 134 135 137 140 143 144 149 150 151 154 ...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%

Subtask #6:

score: 0
Skipped

Dependency #4:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%