問題一覧 > 通常問題

No.3253 Banned Product

レベル : / AI推定難易度 : 1300 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 90
作問者 : Iroha_3856 / テスター : lif4635 champignon tikuwa_
お気に入りにしたユーザー ProblemId : 12561 / 自分の提出
問題文最終更新日: 2025-09-03 15:25:52
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 481 菁々祭プログラミングコンテスト2025 (順位表) の他の問題:

Problem Statement

You are given positive integers $N, K\ (K \leq N)$.

For a positive integer $x$, we define $x$ to be "good" if and only if there is no pair of integers $(a, b)$ such that $1 \leq a, b \leq K$ and $x = a \times b$.

Output the largest good positive integer $x$ that is at most $N$. If no such $x$ exists, output $-1$.

You are given $T$ test cases; solve each of them.

Input

$T$
$case_1$
$case_2$
$\vdots$
$case_T$

Each test case is given in the following format.

$N\ K$

All inputs satisfy the following constraints.

  • $1 \leq T \leq 10$
  • $1 \leq K \leq N \leq 10^9$
  • $N, K$ are integers

Output

Let $answer_i$ be the answer to $case_i$. Output in the following format, followed by a newline at the end.

$answer_1$
$answer_2$
$\vdots$
$answer_T$

Sample

Sample 1
Input
3
16 5
100 100
2 1
Output
14
-1
2

  • Consider the $1$-st test case.

    $x = 14$ is a good number, since there is no pair of integers $(a, b)$ such that $1 \leq a, b \leq 5$ and $x = a \times b$.

    $x = 15, 16$ are not good numbers, since they can be written using positive integers at most $5$ as $15 = 3 \times 5, 16 = 4 \times 4$, respectively.

    Therefore, no good number greater than $14$ exists, so the answer is $14$.

  • For the $2$-nd test case, no good integer $x$ at most $N$ exists.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。