CF762A.k-th divisor

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist.

Divisor of n is any such natural number, that n can be divided by it without remainder.

给你两个整数 nn 和 kk。请找出 nn 的第 kk 小的正因数;若不存在,则报告不存在。

nn 的一个因数是指任意满足 nn 能被其整除(即余数为 00)的正整数。

输入格式

The first line contains two integers n and k (1 ≤ n ≤ 1015, 1 ≤ k ≤ 109).

第一行包含两个整数 nn 和 kk(1 ≤ n ≤ 10151 \leq n \leq 10^{15},1 ≤ k ≤ 1091 \leq k \leq 10^9)。

输出格式

If n has less than k divisors, output -1.

Otherwise, output the k-th smallest divisor of n.

如果 nn 的正因数个数少于 kk,则输出 −1-1。
否则,输出 nn 的第 kk 小的正因数。

输入输出样例

  • 输入#1

    4 2

    输出#1

    2
  • 输入#2

    5 3

    输出#2

    -1
  • 输入#3

    12 5

    输出#3

    6

说明/提示

In the first example, number 4 has three divisors: 1, 2 and 4. The second one is 2.

In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1.

在第一个例子中,数字 4 有三个因数:1、2 和 4。第二个因数是 2。

在第二个例子中,数字 5 只有两个因数:1 和 5。第三个因数不存在,因此答案为 −1-1。

输入解题思路,AI测评打分。不知道怎么写?

首页