結果

問題 No.937 Ultra Sword
ユーザー otamay6otamay6
提出日時 2019-11-21 23:04:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,086 ms / 3,000 ms
コード長 729 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 82,404 KB
実行使用メモリ 96,656 KB
最終ジャッジ日時 2024-05-01 02:23:55
合計ジャッジ時間 23,789 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,464 KB
testcase_01 AC 214 ms
79,492 KB
testcase_02 AC 35 ms
54,248 KB
testcase_03 AC 34 ms
52,704 KB
testcase_04 AC 35 ms
54,844 KB
testcase_05 AC 718 ms
96,428 KB
testcase_06 AC 803 ms
92,980 KB
testcase_07 AC 866 ms
94,084 KB
testcase_08 AC 541 ms
86,260 KB
testcase_09 AC 494 ms
84,688 KB
testcase_10 AC 930 ms
96,124 KB
testcase_11 AC 153 ms
76,824 KB
testcase_12 AC 425 ms
87,996 KB
testcase_13 AC 398 ms
87,796 KB
testcase_14 AC 443 ms
89,784 KB
testcase_15 AC 353 ms
85,452 KB
testcase_16 AC 90 ms
76,340 KB
testcase_17 AC 112 ms
76,684 KB
testcase_18 AC 377 ms
86,620 KB
testcase_19 AC 262 ms
82,040 KB
testcase_20 AC 242 ms
80,520 KB
testcase_21 AC 1,038 ms
96,656 KB
testcase_22 AC 37 ms
53,492 KB
testcase_23 AC 36 ms
53,128 KB
testcase_24 AC 1,086 ms
95,688 KB
testcase_25 AC 739 ms
94,516 KB
testcase_26 AC 720 ms
91,524 KB
testcase_27 AC 666 ms
91,548 KB
testcase_28 AC 796 ms
93,004 KB
testcase_29 AC 265 ms
82,620 KB
testcase_30 AC 702 ms
88,952 KB
testcase_31 AC 850 ms
95,944 KB
testcase_32 AC 580 ms
89,068 KB
testcase_33 AC 837 ms
95,996 KB
testcase_34 AC 371 ms
82,788 KB
testcase_35 AC 282 ms
82,616 KB
testcase_36 AC 735 ms
94,328 KB
testcase_37 AC 305 ms
82,608 KB
testcase_38 AC 645 ms
91,232 KB
testcase_39 AC 271 ms
82,544 KB
testcase_40 AC 713 ms
92,624 KB
testcase_41 AC 405 ms
84,936 KB
testcase_42 AC 601 ms
89,924 KB
testcase_43 AC 597 ms
89,064 KB
testcase_44 AC 391 ms
82,748 KB
testcase_45 AC 477 ms
85,552 KB
testcase_46 AC 529 ms
85,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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(str(bin(x)))
		Ly=len(str(bin(y)))
		y^=x<<(Ly-Lx)
		if x>y:
			x,y=y,x
	return y
def usable(x,g):
    Lx=len(str(bin(x)))
    Lg=len(str(bin(g)))
    while Lx>=Lg and x!=0:
        x^=g<<(Lx-Lg)
        Lx=len(str(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)
0