Advertisement
Sugarhl

Untitled

Apr 23rd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "iostream"
  3. using namespace std;
  4. int main()
  5. {
  6. long long n, ans = 0, q = 0;
  7. cin >> n;
  8. if (n<2)
  9. {
  10. cout << n << endl;
  11. return 0;
  12. }
  13. for (int i = 9; i >= 2; i--)
  14. {
  15. while (n%i == 0)
  16. {
  17. ans = ans * 10 + i;
  18. n = n / i;
  19. //cout << ans << endl;
  20. }
  21. }
  22. if (n != 1)
  23. cout << -1 << endl;
  24. else
  25. {
  26. while (ans > 0)
  27. {
  28. q = ans % 10 + q * 10;
  29. ans = (ans - ans % 10) / 10;
  30. }
  31. cout << q << endl;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement