fork(1) download
  1. #include <stdio.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t,a,max,rem,i;
  8. scanf("%d",&t); rem=0;
  9. while(t--)
  10. {
  11. scanf("%d",&a);
  12. for(i=2;i<=a;i++)
  13. {
  14. if(a%i>=rem)
  15. {
  16. rem=a%i; max=i;
  17. }
  18. }
  19. printf("%d\n",max);
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 2900KB
stdin
4
2
5
53
20
stdout
2
3
27
27