// UVa 993 - Product of digits #include <iostream> using namespace std; #define integer unsigned long long int main() { int t; for (cin >> t; t; t--) { integer n; cin >> n; if (n <= 1) cout << n << endl; else { int sol[10]; for (int i = 9; i > 1; i--) { sol[i] = 0; while (n % i == 0) { n /= i; sol[i]++; } } if (n == 1) { for (int i = 2; i <= 9; i++) { for (; sol[i]; sol[i]--) { cout << i; } } cout << endl; } else cout << -1 << endl; } } return 0; }
No comments:
Post a Comment