1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52#include<iostream>
#include<set>
#include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
int n,k;
cin >> n >> k;
if(n <= k){
cout << 1 << endl;
}
else{
// highest divisor less than equal to k
set<int> divisors;
for(int i = 1; i <= sqrt(n); i++){
if(n%i == 0){
if(i <= k) divisors.insert(i);
if(n/i <= k) divisors.insert(n/i);
}
}
int val = *divisors.rbegin();
cout << n/val << endl;
}
}
return 0;
}
// int find_majority(int n, vector<int>& nums) {
// int count = 0, el = -1;
// for (int i = 0; i < n; i++) {
// if (count == 0) {
// el = nums[i];
// count++;
// } else if (nums[i] == el) {
// count++;
// } else {
// count--;
// }
// }
// count = 0;
// for (int i = 0; i < n; i++) {
// if (nums[i] == el) {
// count++;
// }
// }
// if (count > n / 2) return el;
// return -1;
// }