fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <tgmath.h>
  4.  
  5.  
  6. int main()
  7. {
  8. long N;
  9. scanf("%d", &N);
  10. N = abs (N);
  11. long T = round(sqrt(N)) +1 ;
  12. long a[T];
  13. int Z = 0;
  14. unsigned long i = 0;
  15. while (i <= T) {
  16. a[i] = 1;
  17. if (i == 0)
  18. a[i] = 0;
  19. i++;
  20. }
  21. for (unsigned long i = 2; i <= T; i++) //43
  22. if (a[i] == 1) {
  23. if (N % i == 0)
  24. Z = 1;
  25. for (unsigned long j = i*i; j <= T; j += i)
  26. a[j] = 0;
  27. }
  28. if (Z != 1) {
  29. for (unsigned long i = T; i > 0; i--)
  30. if ((a[i] != 0) && (N % i == 0)) {
  31. printf("%lu", i);
  32. break;
  33. }
  34. }
  35. else
  36. {
  37. printf("%lu", N);
  38. }
  39. return 0;
  40. }
  41.  
  42.  
Success #stdin #stdout 0s 10528KB
stdin
1874657754
stdout
1874657754