結果

問題 No.937 Ultra Sword
ユーザー maspymaspy
提出日時 2020-03-28 16:56:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 10,900 KB
実行使用メモリ 20,492 KB
最終ジャッジ日時 2023-08-30 17:59:43
合計ジャッジ時間 17,505 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 253 ms
13,028 KB
testcase_01 AC 244 ms
13,000 KB
testcase_02 AC 244 ms
12,936 KB
testcase_03 AC 240 ms
12,952 KB
testcase_04 AC 237 ms
12,880 KB
testcase_05 AC 295 ms
17,952 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 246 ms
13,028 KB
testcase_24 AC 367 ms
17,884 KB
testcase_25 AC 322 ms
17,512 KB
testcase_26 AC 313 ms
16,496 KB
testcase_27 AC 311 ms
16,248 KB
testcase_28 AC 329 ms
16,624 KB
testcase_29 AC 238 ms
13,180 KB
testcase_30 AC 310 ms
15,832 KB
testcase_31 AC 332 ms
17,668 KB
testcase_32 AC 293 ms
15,764 KB
testcase_33 AC 332 ms
17,824 KB
testcase_34 AC 254 ms
13,640 KB
testcase_35 AC 249 ms
13,328 KB
testcase_36 AC 319 ms
16,604 KB
testcase_37 AC 243 ms
13,200 KB
testcase_38 AC 307 ms
16,432 KB
testcase_39 AC 245 ms
13,212 KB
testcase_40 AC 314 ms
16,452 KB
testcase_41 AC 266 ms
14,556 KB
testcase_42 AC 298 ms
16,228 KB
testcase_43 AC 299 ms
16,176 KB
testcase_44 AC 271 ms
14,152 KB
testcase_45 AC 283 ms
15,400 KB
testcase_46 AC 288 ms
15,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/ python3.8
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from functools import reduce

U = 10 ** 5
N, *A = map(int, read().split())
num_count = [0] * (U + 1)
for x in A:
    num_count[x] += 1

save_cost = [0] * (U + 1)
for d in range(2, U + 1):
    save_cost[d] = sum((n - n // d) * num_count[n] for n in range(d, U + 1, d))


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        LA = a.bit_length()
        LB = b.bit_length()
        a ^= b << (LA - LB)
        if a < b:
            a, b = b, a
    return a


g = reduce(gcd, A)
cand = [g]
for i in range(1, 17):
    cand += [x ^ (g << i) for x in cand]
max_save = 0
for d in cand:
    if 1 <= d <= U:
        x = save_cost[d]
        if max_save < x:
            max_save = x

answer = sum(A) - max_save
print(answer)
0