結果

問題 No.937 Ultra Sword
ユーザー pekempeypekempey
提出日時 2019-11-30 15:05:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 248 ms / 3,000 ms
コード長 524 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 86,900 KB
実行使用メモリ 92,620 KB
最終ジャッジ日時 2023-08-13 09:31:25
合計ジャッジ時間 12,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 191 ms
80,068 KB
testcase_01 AC 192 ms
79,864 KB
testcase_02 AC 191 ms
80,072 KB
testcase_03 AC 192 ms
80,060 KB
testcase_04 AC 199 ms
80,344 KB
testcase_05 AC 240 ms
92,616 KB
testcase_06 AC 229 ms
88,724 KB
testcase_07 AC 229 ms
90,732 KB
testcase_08 AC 211 ms
83,224 KB
testcase_09 AC 204 ms
81,308 KB
testcase_10 AC 233 ms
92,180 KB
testcase_11 AC 208 ms
80,436 KB
testcase_12 AC 229 ms
90,376 KB
testcase_13 AC 219 ms
90,232 KB
testcase_14 AC 224 ms
92,024 KB
testcase_15 AC 219 ms
87,456 KB
testcase_16 AC 193 ms
80,312 KB
testcase_17 AC 200 ms
80,424 KB
testcase_18 AC 219 ms
88,660 KB
testcase_19 AC 208 ms
84,780 KB
testcase_20 AC 209 ms
83,132 KB
testcase_21 AC 227 ms
92,296 KB
testcase_22 AC 194 ms
80,056 KB
testcase_23 AC 190 ms
80,112 KB
testcase_24 AC 224 ms
92,620 KB
testcase_25 AC 234 ms
90,684 KB
testcase_26 AC 224 ms
87,660 KB
testcase_27 AC 231 ms
87,724 KB
testcase_28 AC 231 ms
88,896 KB
testcase_29 AC 211 ms
80,480 KB
testcase_30 AC 220 ms
85,284 KB
testcase_31 AC 241 ms
92,516 KB
testcase_32 AC 228 ms
85,336 KB
testcase_33 AC 248 ms
92,336 KB
testcase_34 AC 209 ms
80,648 KB
testcase_35 AC 215 ms
80,412 KB
testcase_36 AC 236 ms
90,660 KB
testcase_37 AC 212 ms
80,392 KB
testcase_38 AC 228 ms
87,608 KB
testcase_39 AC 217 ms
80,712 KB
testcase_40 AC 236 ms
88,856 KB
testcase_41 AC 217 ms
81,904 KB
testcase_42 AC 230 ms
86,044 KB
testcase_43 AC 221 ms
85,132 KB
testcase_44 AC 208 ms
80,348 KB
testcase_45 AC 222 ms
82,280 KB
testcase_46 AC 210 ms
82,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce

N = int(input())
A = list(map(int, input().split()))

lg = [0] * (1 << 17)
for i in range(1, 1 << 17):
  lg[i] = lg[i >> 1] + 1

def gcd(x, y):
  while y != 0:
    if x < y:
      x, y = y, x
    else:
      k = lg[x] - lg[y]
      x ^= y << k
  return x

g = reduce(gcd, A)

f = [0] * 100001
for x in A: f[x] += x

souwa = sum(A)
ans = 10**100

for i in range(1, 100001):
  s = sum(f[j] for j in range(i, 100001, i))
  if gcd(i, g) == g:
    ans = min(ans, souwa - s + s // i)

print(ans)

  
0