No.3485 Find 495-like Number
タグ : / 解いたユーザー数 29
作問者 : 👑
hamamu
Problem Statement
An integer that can be expressed as $n = a^2bc$ using odd primes $a, b, c$ satisfying $a < b < c$, such as $495 = 3^2 \times 5 \times 11$, is called a 495-like number.
You are given positive integers $L, R(L \leq R)$. Determine whether there exists an integer $x$ satisfying $L \leq x \leq R$ that is a 495-like number, and if one exists, find $1$ such integer.
Constraints
- All inputs are integers.
- $1 \leq L \leq R \leq 4.95 \times 10^{14}$
Input
The input is given from standard input in the following format.
$L$ $R$
Output
If there exists a 495-like number $x$ satisfying $L \leq x \leq R$, print $1$ such number; otherwise, print $-1$. If there are multiple values of $x$ satisfying the condition, any of them will be accepted.
Sample
Sample 1
Input
485 505
Output
495
$495 = 3^2 \times 5 \times 11$, which is a 495-like Number, so print $495$.
Note that $492 = 2^2 \times 3 \times 41$ is not a 495-like Number because $a = 2$ is not an odd prime.
Sample 2
Input
1 100
Output
-1
There is no 495-like Number among the integers between $1$ and $100$, inclusive. Therefore, print $-1$.
Sample 3
Input
494000000000000 495000000000000
Output
494000000000001
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。