fork download
  1. import java.util.*;
  2.  
  3. public class Main
  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;int max=1;
  17. x=sc.nextInt();
  18. for(int i=1;i<x;i++)
  19. {
  20. if(x%i==0)
  21. {
  22.  
  23. if((max+max)<(i+i))
  24. {
  25. System.out.print("rr"+max+" max "+max+" <"+(i+i)+" ");
  26. max=i;
  27. System.out.print("rr"+max+" max"+"");
  28. }
  29. }
  30.  
  31. }
  32. System.out.println();
  33. if(max!=1)
  34. System.out.println(max);
  35. else
  36. System.out.println(x-1);
  37. }
  38. }
  39.  
  40.  
  41.  
Success #stdin #stdout 0.22s 59288KB
stdin
7
10
7
21
100
2
1000
6
stdout
rr1 max 1 <4     rr2 maxrr2 max 2 <10     rr5 max
5

6
rr1 max 1 <6     rr3 maxrr3 max 3 <14     rr7 max
7
rr1 max 1 <4     rr2 maxrr2 max 2 <8     rr4 maxrr4 max 4 <10     rr5 maxrr5 max 5 <20     rr10 maxrr10 max 10 <40     rr20 maxrr20 max 20 <50     rr25 maxrr25 max 25 <100     rr50 max
50

1
rr1 max 1 <4     rr2 maxrr2 max 2 <8     rr4 maxrr4 max 4 <10     rr5 maxrr5 max 5 <16     rr8 maxrr8 max 8 <20     rr10 maxrr10 max 10 <40     rr20 maxrr20 max 20 <50     rr25 maxrr25 max 25 <80     rr40 maxrr40 max 40 <100     rr50 maxrr50 max 50 <200     rr100 maxrr100 max 100 <250     rr125 maxrr125 max 125 <400     rr200 maxrr200 max 200 <500     rr250 maxrr250 max 250 <1000     rr500 max
500
rr1 max 1 <4     rr2 maxrr2 max 2 <6     rr3 max
3