codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

762A.md (958B)


      1 Source: https://codeforces.com/problemset/problem/762/A
      2 
      3 A. k-th divisor
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 You are given two integers *n* and *k*. Find *k*-th smallest divisor of *n*, or report that it doesn't exist.
     22 
     23 Divisor of *n* is any such natural number, that *n* can be divided by it without remainder.
     24 
     25 Input
     26 
     27 The first line contains two integers *n* and *k* (1 ≤ *n* ≤ 1015, 1 ≤ *k* ≤ 109).
     28 
     29 Output
     30 
     31 If *n* has less than *k* divisors, output -1.
     32 
     33 Otherwise, output the *k*-th smallest divisor of *n*.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 4 2
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 2
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 5 3
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 -1
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 12 5
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 6
     71 ```
     72 
     73 Note
     74 
     75 In the first example, number 4 has three divisors: 1, 2 and 4. The second one is 2.
     76 
     77 In the second example, number 5 has only two divisors: 1 and 5. The third divisor doesn't exist, so the answer is -1.