codeforces-scrape

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

1360D.md (1808B)


      1 Source: https://codeforces.com/problemset/problem/1360/D
      2 
      3 D. Buying Shovels
      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 Polycarp wants to buy exactly $n$ shovels. The shop sells packages with shovels. The store has $k$ types of packages: the package of the $i$-th type consists of exactly $i$ shovels ($1 \le i \le k$). The store has an infinite number of packages of each type.
     22 
     23 Polycarp wants to choose one type of packages and then buy several (one or more) packages of this type. What is the smallest number of packages Polycarp will have to buy to get exactly $n$ shovels?
     24 
     25 For example, if $n=8$ and $k=7$, then Polycarp will buy $2$ packages of $4$ shovels.
     26 
     27 Help Polycarp find the minimum number of packages that he needs to buy, given that he:
     28 
     29 * will buy exactly $n$ shovels in total;
     30 * the sizes of all packages he will buy are all the same and the number of shovels in each package is an integer from $1$ to $k$, inclusive.
     31 
     32 Input
     33 
     34 The first line contains an integer $t$ ($1 \le t \le 100$) — the number of test cases in the input. Then, $t$ test cases follow, one per line.
     35 
     36 Each test case consists of two positive integers $n$ ($1 \le n \le 10^9$) and $k$ ($1 \le k \le 10^9$) — the number of shovels and the number of types of packages.
     37 
     38 Output
     39 
     40 Print $t$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
     41 
     42 Example
     43 
     44 Input
     45 
     46 ```
     47 5
     48 8 7
     49 8 1
     50 6 10
     51 999999733 999999732
     52 999999733 999999733
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 2
     59 8
     60 1
     61 999999733
     62 1
     63 ```
     64 
     65 Note
     66 
     67 The answer to the first test case was explained in the statement.
     68 
     69 In the second test case, there is only one way to buy $8$ shovels — $8$ packages of one shovel.
     70 
     71 In the third test case, you need to buy a $1$ package of $6$ shovels.