Advertisement
erfanul007

Timus 1014

Oct 29th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int a[20];
  6. int i,j,k,n,m,temp;
  7. scanf("%d",&n);
  8. if(n==0)
  9. printf("10\n");
  10. else if(n<10)
  11. printf("%d\n",n);
  12. else{
  13. m=0;
  14. for(i=9;i>=2;i--)
  15. while(n%i==0)
  16. {
  17. n=n/i;
  18. m++;
  19. a[m]=i;
  20. }
  21.  
  22. if(n>1)
  23. printf("-1\n");
  24. else{
  25. for(j=1;j<=m;j++){
  26. for(k=j+1;k<=m;k++){
  27. if(a[j]>a[k]){
  28. temp=a[j];
  29. a[j]=a[k];
  30. a[k]=temp;
  31. }
  32. }
  33.  
  34. }
  35. for(j=1;j<=m;j++)
  36. printf("%d",a[j]);
  37. printf("\n");
  38.  
  39. }
  40. }
  41.  
  42. return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement