Logo
(追記) (追記ここまで)

31335번 - What the Flex? 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
0.5 초 1024 MB158353021.127%

문제

\textit{In this problem, you have to find the next integer in a particular ordering with has the same set of prime divisors.}

Archaeologist Kris studies the ancient platform Flex which was recently found near Adobe creek. On this platform, the numbers of different versions of teleporters which have been created by The Elders were once inscribed. Each version number is an integer between 1ドル$ and $N$. On the platform, there are several columns of numbers, one for each teleporter. Each column once listed all created versions of a teleporter in the order they were built. Unfortunately, some of the numbers were erased.

Kris just finished studying version $a$ of teleporter $b,ドル and he is now ready to examine the next version of this teleporter. But he does not even know its number! On the other hand, any program which is a correct solution of this problem must know it. Below is what Kris already knows about the version numbers of the teleporters:

  1. Each number from 1ドル$ to $N$ is the number of some version of some teleporter.
  2. Different versions of one teleporter have different numbers.
  3. Each teleporter has its own set of prime numbers. Later, we consider one fixed teleporter. Let its prime number set be $X = \{p_1, p_2, \dots, p_m\}$ (we list them so that $p_1 < p_2 < \dots < p_m$).
  4. It is known that any version number of this teleporter is divisible by each prime from $X$ and not divisible by primes not in X. It means that such number can be written as $p_1^{k_1} p_2^{k_2} \dots p_m^{k_m}$ where $k_i \ge 1$. So, each version of this teleporter can be mapped to a tuple of $m$ positive integers $(k_1, k_2, \dots, k_m)$.
  5. Version $\alpha = (k_1, k_2, \dots, k_m)$ was built before version $\beta = (l_1, l_2, \dots, l_m)$ if and only if there is such $i$ (0ドル \le i < m$) that $k_1 = l_1,ドル $k_2 = l_2,ドル $\dots,ドル $k_i = l_i,ドル but $k_{i+1} < l_{i+1}$. It can be said that the versions are ordered lexicographically by their tuples.

입력

The only line of input contains two integers --- the version number $a$ of a teleporter and the number $N$ (1ドル \le a \le N \le 10^{18}$).

출력

If there exists a version of the same teleporter which was built just after version $a,ドル print its number. Otherwise, print "-1".

제한

예제 입력 1

6 13

예제 출력 1

12

예제 입력 2

12 13

예제 출력 2

-1

힌트

출처

Contest > Open Cup > 2014/2015 Season > Stage 5: Grand Prix of Peterhof K번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /