No.3253 Banned Product
タグ : / 解いたユーザー数 90
作問者 :
Iroha_3856
/ テスター :
champignon
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もしくは右上の雲マークをクリックしてアカウントを作成してください。