fork download
  1. import java.util.*;
  2.  
  3. class Ideone
  4. {
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. int t = sc.nextInt();
  8. while (t-- > 0) {
  9. solve(sc);
  10. }
  11. sc.close();
  12. }
  13.  
  14. public static void solve(Scanner sc)
  15. {
  16. int x=0;
  17. x=sc.nextInt();
  18. int max=1;
  19. for(int i=1;i<x;i++)
  20. {
  21. if(x%i==0)
  22. {
  23. if(max<(i+i))
  24. {
  25. max=i;
  26. }
  27. }
  28.  
  29. }
  30. System.out.println(max);
  31.  
  32. }
  33.  
  34. }
  35.  
  36.  
Success #stdin #stdout 0.18s 56624KB
stdin
7
10
7
21
100
2
1000
6
stdout
5
1
7
50
1
500
3