結果

問題 No.1917 LCMST
ユーザー PNJ
提出日時 2024-08-29 19:35:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 458 bytes
コンパイル時間 3,673 ms
コンパイル使用メモリ 82,196 KB
実行使用メモリ 226,044 KB
最終ジャッジ日時 2024-08-29 19:36:02
合計ジャッジ時間 15,611 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int,input().split()))
M = 100000
B = [0] * (M + 1)
m = min(A)
if m == 1:
  print(sum(A) - 1)
  exit()
for a in A:
  B[a] += 1

ans = 0
for a in range(2,M):
  if B[a] == 0:
    continue
  ans += m * (B[a] - 1)
  B[a] = 1
  res = 0
  for i in range(2,M + 1):
    if a * i > M:
      break
    res += B[a * i] * a * i
    B[a * i] = 0
  ans += res
for a in range(m + 1,M + 1):
  if B[a] == 0:
    continue
  ans += a * m
print(ans)
0