Original Problem

Approach


Consensus

Conclusion

Space & Time Analysis


The analysis method we are using is Algorithm Complexity Analysis

Space - O()

  • Ignore input size & language dependent space

Time - O()

Codes


1st Attempt (Java)

import java.util.*;
 
public class Solution {
static Scanner scanner = new Scanner(System.in);
 
// Write your solution here
public static void solve() {
  long x = scanner.nextLong();
  long n = scanner.nextLong();
 
  long res = 1;
 
  for (int i=1; i<=Math.sqrt(x); i++) {
    if (x%i == 0) {
      if (i * n > x) break;
      
      res = Math.max(res, i);
 
      long oppFactor = x/i;
      if (oppFactor * n <= x) res = Math.max(res, oppFactor);
    }
  }
 
  System.out.println(res);
}
 
public static void main(String[] args) {
  int t = scanner.nextInt();
  scanner.nextLine();
  
  while(t-- > 0) {
    solve();
  }
}
}

Personal Reflection


  • Why it takes so long to solve: NIL
  • What you could have done better: NIL
  • What you missed: NIL
  • Ideas you’ve seen before: NIL
  • Ideas you found here that could help you later: NIL
  • Ideas that didn’t work and why: NIL