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=x-1;
  19. for(int i=1;i<x;i++)
  20. {
  21. if(x%i==0)
  22. {
  23. if(max==x-1)
  24. max=Math.max(max+1,i+i);
  25. else
  26. max=Math.max(max,i+i);
  27. }
  28.  
  29. }
  30. if(max==x-1)
  31. System.out.println(max);
  32. else
  33. {
  34. System.out.println(max/2);
  35. }
  36. }
  37.  
  38. }
  39.  
  40.  
Success #stdin #stdout 0.13s 54708KB
stdin
7
10
7
21
100
2
1000
6
stdout
5
3
10
50
1
500
3