結果
問題 |
No.937 Ultra Sword
|
ユーザー |
![]() |
提出日時 | 2019-11-24 08:51:14 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 706 bytes |
コンパイル時間 | 397 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 37,968 KB |
最終ジャッジ日時 | 2024-11-21 02:09:39 |
合計ジャッジ時間 | 100,283 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 28 TLE * 19 |
ソースコード
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 while x!=0: Lx=len(bin(x)) Ly=len(bin(y)) y^=x<<(Ly-Lx) if x>y: x,y=y,x 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) 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)