結果

問題 No.1917 LCMST
ユーザー ああいいああいい
提出日時 2022-04-29 23:37:50
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 526 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 260,256 KB
最終ジャッジ日時 2023-09-11 15:17:11
合計ジャッジ時間 36,969 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
89,696 KB
testcase_01 AC 140 ms
89,904 KB
testcase_02 AC 140 ms
89,828 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 135 ms
89,824 KB
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 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 619 ms
253,664 KB
testcase_30 AC 650 ms
254,008 KB
testcase_31 AC 628 ms
254,264 KB
testcase_32 AC 619 ms
252,420 KB
testcase_33 AC 632 ms
253,432 KB
testcase_34 AC 354 ms
252,488 KB
testcase_35 AC 355 ms
251,260 KB
testcase_36 AC 379 ms
252,248 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def lcm(a,b):
    x,y = a,b
    while True:
        r = a % b
        a = b
        b = r
        if r == 0:
            return x // a * y

N = int(input())
A = list(map(int,input().split()))
A.sort()
inf = 10 ** 6
C = 10 ** 5 + 1
dat = [inf] * C
count = [0] * C
for a in A:
    dat[a] = a
    count[a] += 1
era = [0] * C
d = [[] for _ in range(C)]
for i in range(2,C):
    if era[i] == 0:
        for j in range(i,C,i):
            era[j] = 1
        for j in range(i * 2,C,i):
            d[j].append(i)
        for j in range((C-1) // i,0,-1):
            #print(j,j * i)
            dat[j] = min(dat[j],dat[j * i])
ans = 0

for i in range(1,N):
    a = A[i]
    tmp = inf
    for j in d[a]:
        if dat[j] < a:
            c = lcm(a,dat[j])
            if c < tmp:
                tmp = c
    if count[a] > 1:
        if tmp > a:
            tmp = a
    if i == 0:
        c = A[0] * A[1]
        if c < tmp:
            tmp = c
    else:
        c = a * A[0]
        if c < tmp:
            tmp = c
    ans += tmp
print(ans)
0