結果

問題 No.531 エヌスクミ島の平和協定
ユーザー gew1fw
提出日時 2025-06-12 14:50:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 593 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 82,364 KB
実行使用メモリ 53,812 KB
最終ジャッジ日時 2025-06-12 14:53:49
合計ジャッジ時間 2,967 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 37
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

n, m = map(int, input().split())

def get_divisors(n):
    divisors = set()
    for i in range(1, int(math.isqrt(n)) + 1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
    return sorted(divisors)

divisors = get_divisors(n)
divisors_set = set(divisors)

possible_ds = []

for d in divisors:
    if d == n:
        if d <= m:
            possible_ds.append(d)
    else:
        if (n - d) in divisors_set and d <= m:
            possible_ds.append(d)

if not possible_ds:
    print(-1)
else:
    max_d = max(possible_ds)
    print(n // max_d)
0