fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. int a, b, max, min, n2, i;
  10.  
  11. int T;
  12. scanf("%d", & T);
  13.  
  14. while (T--) {
  15. int n;
  16. scanf("%d", &n);
  17. int count = 0;
  18. min = n;
  19. while (n != 0) {
  20. for (a = 2; a < n; a++) {
  21. if (n % a == 0) {
  22. b = n / a;
  23. if (a >= b)
  24. max = a;
  25. else if (b > a)
  26. max = b;
  27. }
  28. if (min > max)
  29. min = max;
  30. }
  31.  
  32. n2 = n - 1;
  33. if (n2 < min) {
  34. n = n2;
  35. count = count + 1;
  36. } else {
  37. n = min;
  38. count = count + 1;
  39. }
  40. }
  41. printf("%d\n", count);
  42. }
  43. return 0;
  44. }
Success #stdin #stdout 0s 4340KB
stdin
2
3
4
stdout
1
3