fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define int long long
  4.  
  5. int32_t main() {
  6. int t;
  7. cin >> t;
  8. while (t--) {
  9. int n, k;
  10. cin >> n >> k;
  11.  
  12. int chosen = 1;
  13. for (int i = 1; i * i <= n; ++i) {
  14. if (n % i == 0) {
  15. if (i <= k) chosen = max(chosen, i);
  16. int j = n / i;
  17. if (j <= k) chosen = max(chosen, j);
  18. }
  19. }
  20.  
  21. cout << n / chosen << '\n';
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 5320KB
stdin
5
8 7
8 1
6 10
999999733 999999732
999999733 999999733



stdout
2
8
1
999999733
1