Saleh127

UVA 993.cpp

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