Advertisement
erfanul007

Untitled

Jan 20th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int > pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define sc scanf
  14. #define pf printf
  15. #define sci(n) scanf("%d",&n)
  16. #define scl(n) scanf("%I64d",&n)
  17. #define scf(n) scanf("%lf",&n)
  18. #define pfi(n) printf("%d",n)
  19. #define pfl(n) printf("%I64d",n)
  20. #define pff(n) cout<<n
  21. #define line printf("\n")
  22. #define spc printf(" ")
  23. #define loop(i,x,y) for(int i=int(x); i<=int(y); i++)
  24. #define rloop(i,y,x) for(int i=int(y); i>=int(x); i--)
  25. #define cspf(i) printf("Case %d: ", i)
  26. #define pb push_back
  27. #define mp make_pair
  28. #define ff first
  29. #define ss second
  30. #define all(v) v.begin(),v.end()
  31. #define rall(v) v.rbegin(),v.rend()
  32. #define read() freopen("input.txt", "r", stdin)
  33. #define write() freopen("output.txt", "w", stdout)
  34. /// Constants
  35. #define eps 1e-9
  36. #define PI acos(-1.0) // 3.1415926535897932
  37.  
  38. ll digit(int x)
  39. {
  40. rloop(i,9,2){
  41. if(x%i==0)
  42. return i;
  43. }
  44. return -1;
  45. }
  46.  
  47. int main()
  48. {
  49. read();
  50. write();
  51. int n; sci(n);
  52. loop(i,1,n){
  53. vi vt;
  54. int x,k; sci(x);
  55. int flg=0;
  56. while(x/10>0){
  57. k=digit(x);
  58. if(k==-1){
  59. flg=1;
  60. break;
  61. }
  62. vt.pb(k);
  63. x/=k;
  64. }
  65. if(flg==1)
  66. pf("-1\n");
  67. else{
  68. vt.pb(x);
  69. sort(all(vt));
  70. int sz=vt.size();
  71. loop(j,0,sz-1)
  72. pfi(vt[j]);
  73. line;
  74. }
  75. vt.clear();
  76. }
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement