結果

問題 No.3253 Banned Product
ユーザー norioc
提出日時 2025-09-09 01:12:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 695 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 82,108 KB
実行使用メモリ 59,940 KB
最終ジャッジ日時 2025-09-09 01:12:57
合計ジャッジ時間 1,618 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(n: int) -> list[int]:
    """n の約数を求める"""
    s = set()
    p = 1
    while p * p <= n:
        if n % p == 0:
            s.add(p)
            s.add(n // p)
        p += 1
    return sorted(s)


def solve():
    N, K = map(int, input().split())

    for x in reversed(range(max(1, N-281), N+1)):
        ok = True
        p = 1
        while p * p <= x:
            if x % p == 0:
                a = p
                b = x // p
                if a <= K and b <= K:
                    ok = False
                    break
            p += 1

        if ok:
            return x

    return -1


T = int(input())
for _ in range(T):
    ans = solve()
    print(ans)
0