結果

問題 No.937 Ultra Sword
ユーザー pekempeypekempey
提出日時 2019-11-30 15:05:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 187 ms / 3,000 ms
コード長 524 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 91,992 KB
最終ジャッジ日時 2024-05-01 03:05:41
合計ジャッジ時間 9,802 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
78,724 KB
testcase_01 AC 138 ms
78,764 KB
testcase_02 AC 140 ms
78,676 KB
testcase_03 AC 133 ms
79,032 KB
testcase_04 AC 151 ms
78,908 KB
testcase_05 AC 181 ms
91,992 KB
testcase_06 AC 171 ms
87,912 KB
testcase_07 AC 178 ms
89,260 KB
testcase_08 AC 162 ms
82,532 KB
testcase_09 AC 152 ms
80,032 KB
testcase_10 AC 177 ms
91,036 KB
testcase_11 AC 150 ms
79,372 KB
testcase_12 AC 172 ms
89,124 KB
testcase_13 AC 169 ms
89,256 KB
testcase_14 AC 177 ms
90,584 KB
testcase_15 AC 166 ms
86,016 KB
testcase_16 AC 145 ms
78,800 KB
testcase_17 AC 152 ms
79,228 KB
testcase_18 AC 173 ms
87,680 KB
testcase_19 AC 163 ms
83,300 KB
testcase_20 AC 157 ms
81,840 KB
testcase_21 AC 171 ms
91,252 KB
testcase_22 AC 142 ms
78,808 KB
testcase_23 AC 143 ms
78,840 KB
testcase_24 AC 173 ms
91,220 KB
testcase_25 AC 180 ms
89,244 KB
testcase_26 AC 172 ms
86,560 KB
testcase_27 AC 178 ms
86,288 KB
testcase_28 AC 171 ms
87,772 KB
testcase_29 AC 153 ms
79,060 KB
testcase_30 AC 165 ms
84,704 KB
testcase_31 AC 184 ms
91,324 KB
testcase_32 AC 170 ms
84,372 KB
testcase_33 AC 187 ms
90,920 KB
testcase_34 AC 155 ms
79,124 KB
testcase_35 AC 159 ms
79,128 KB
testcase_36 AC 184 ms
89,132 KB
testcase_37 AC 154 ms
79,036 KB
testcase_38 AC 171 ms
86,408 KB
testcase_39 AC 153 ms
79,352 KB
testcase_40 AC 179 ms
87,568 KB
testcase_41 AC 169 ms
80,824 KB
testcase_42 AC 183 ms
85,028 KB
testcase_43 AC 173 ms
84,652 KB
testcase_44 AC 151 ms
79,104 KB
testcase_45 AC 167 ms
81,388 KB
testcase_46 AC 156 ms
81,312 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