k-th divisor

题意翻译

## 题目描述 你被给了两个整数$n$ 和$k$ 。找到$n$ 的第$k$ 小因子,或者告知其不存在。 任意一个可以除$n$ 而没有余数的自然数都是$n$ 的因子。 ### 输入格式: 第一行包含两个整数$n$ 和$k$ ($1\leq n\leq 10^{15}$ ,$1\leq k\leq 10^9$ ) ### 输出格式: 如果$n$ 不足$k$ 个因子输出-1。 否则输出$n$ 的第$k$ 小的因子。 ### 说明 在第一个样例中,数字$4$ 有三个因子:$1$ ,$2$ 和$4$ 。第二小的为$2$ 。 在第二个样例中,数字$5$ 仅有两个因子$1$ 和$5$ 。第三个因子是不存在的,因此答案是-1。 感谢@Khassar 提供的翻译

题目描述

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.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1<=n<=10^{15} $ , $ 1<=k<=10^{9} $ ).

输出格式


If $ n $ has less than $ k $ divisors, output -1. Otherwise, output the $ k $ -th smallest divisor of $ n $ .

输入输出样例

输入样例 #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.