結果

問題 No.1917 LCMST
ユーザー gew1fw
提出日時 2025-06-12 20:01:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 472 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 82,332 KB
実行使用メモリ 224,856 KB
最終ジャッジ日時 2025-06-12 20:05:53
合計ジャッジ時間 14,094 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math

def main():
    input = sys.stdin.read().split()
    n = int(input[0])
    a = list(map(int, input[1:n+1]))
    
    m = min(a)
    count_m = a.count(m)
    
    sum_m = m * (count_m - 1)
    
    sum_other = 0
    for num in a:
        if num == m:
            continue
        gcd = math.gcd(m, num)
        lcm = (m * num) // gcd
        sum_other += lcm
    
    total = sum_m + sum_other
    print(total)

if __name__ == '__main__':
    main()
0