結果

問題 No.2570 最大最大公約数
ユーザー hirayuu_ychirayuu_yc
提出日時 2023-12-02 15:41:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 368 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 64,304 KB
最終ジャッジ日時 2023-12-02 15:41:09
合計ジャッジ時間 5,444 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 154 ms
64,304 KB
testcase_01 AC 167 ms
64,300 KB
testcase_02 AC 196 ms
64,300 KB
testcase_03 AC 107 ms
64,304 KB
testcase_04 AC 135 ms
64,304 KB
testcase_05 AC 168 ms
64,304 KB
testcase_06 AC 160 ms
64,300 KB
testcase_07 AC 182 ms
64,304 KB
testcase_08 AC 196 ms
64,304 KB
testcase_09 AC 151 ms
64,304 KB
testcase_10 AC 210 ms
64,304 KB
testcase_11 AC 125 ms
64,304 KB
testcase_12 AC 189 ms
64,304 KB
testcase_13 AC 76 ms
62,236 KB
testcase_14 AC 191 ms
64,304 KB
testcase_15 AC 193 ms
64,300 KB
testcase_16 AC 179 ms
64,304 KB
testcase_17 AC 34 ms
53,460 KB
testcase_18 AC 42 ms
61,848 KB
testcase_19 AC 44 ms
61,980 KB
testcase_20 AC 43 ms
61,984 KB
testcase_21 AC 44 ms
61,984 KB
testcase_22 AC 43 ms
61,980 KB
testcase_23 AC 41 ms
61,984 KB
testcase_24 AC 43 ms
61,988 KB
testcase_25 AC 46 ms
61,848 KB
testcase_26 AC 42 ms
61,980 KB
testcase_27 AC 42 ms
61,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
A=list(map(int,input().split()))
ans=0
cha=set()
for i in range(max(1,A[0]-102),A[0]+102):
    for j in range(1,i+1):
        if j*j>i:
            break
        if i%j==0:
            cha.add(j)
            cha.add(i//j)
for i in cha:
    now=0
    for j in A:
        now+=min(j%i,(-j)%i)
    if now<=K:
        ans=max(ans,i)
print(ans)
0