fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int p = -1, k = 0;
  8. for (int i = 2; i <= n; i++)
  9. {
  10. bool ok = 1;
  11. for (int j = 2; j <= i / j; j++)
  12. {
  13. if (i % j == 0)
  14. {
  15. ok = 0;
  16. }
  17. }
  18. if (ok == 1)
  19. {
  20. if (n % i == 0)
  21. {
  22. int temp = 1;
  23. while (temp < n)
  24. {
  25. temp *= i;
  26. k++;
  27. }
  28. if (temp == n)
  29. p = i;
  30. }
  31. }
  32. else
  33. continue;
  34. }
  35. if (p == -1)
  36. cout << "NO\n";
  37. else
  38. {
  39. cout << "YES\n";
  40. cout << p << ' ' << k;
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0.02s 5320KB
stdin
Standard input is empty
stdout
NO