結果
| 問題 |
No.937 Ultra Sword
|
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2019-11-25 21:33:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,341 ms / 3,000 ms |
| コード長 | 838 bytes |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 82,580 KB |
| 実行使用メモリ | 181,596 KB |
| 最終ジャッジ日時 | 2024-11-21 02:18:19 |
| 合計ジャッジ時間 | 30,367 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 47 |
ソースコード
import sys
input = sys.stdin.readline
N = int(input().rstrip('\n'))
A = list(map(int, input().rstrip('\n').split()))
def GCD(x,y):
if x>y:
x,y=y,x
Lx=len(bin(x))
Ly=len(bin(y))
if x!=0:
return GCD(x,y^(x<<(Ly-Lx)))
else:
return y
def usable(x,g):
Lx=len(bin(x))
Lg=len(bin(g))
while Lx>=Lg and x!=0:
x^=g<<(Lx-Lg)
Lx=len(bin(x))
return x==0
S=sum(A)
M=max(A)
mi=[0]
for i in range(M):
mi.append(0)
div = [[]]*(M+1)
for i in range(1,M+1):
j=i
while j<=M:
div[j].append(i)
j+=i
G=0
for x in A:
G=GCD(G,x)
j=1
while j*j<=x:
if x%j==0:
mi[j]+=x-x//j
if j*j!=x:
mi[x//j]+=x-j
j+=1
X=S
for i in range(2,M+1):
if(usable(i,G)):
X=min(X,S-mi[i])
print(X)
otamay6