Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include<iostream>
  2. #include<algorithm>
  3. #include<math.h>
  4. #include<stdio.h>
  5. #define SIZE 100
  6.  
  7. using namespace std;
  8.  
  9. long long n;
  10. int len = 0, a[SIZE];
  11.  
  12. int main()
  13. {
  14. freopen("input.txt","r",stdin);
  15. freopen("output.txt","w",stdout);
  16.  
  17. cin >> n;
  18.  
  19. if(n == 1)
  20. {
  21. cout << "1\n";
  22. return 0;
  23. }
  24.  
  25. if(n == 0)
  26. {
  27. cout << "10\n";
  28. return 0;
  29. }
  30.  
  31. for(int i = 9; i > 1; i--)
  32. while(n%i == 0)
  33. {
  34. n /= i;
  35. a[len] = i;
  36. len++;
  37. }
  38.  
  39. if(n != 1)
  40. {
  41. cout << "-1\n";
  42. return 0;
  43. }
  44.  
  45. while(len > 0)
  46. {
  47. len--;
  48. cout << a[len];
  49. }
  50.  
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement