Created
October 3, 2015 06:21
-
-
Save swt02026/440d9623b51f8c0c9fcd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <iterator> | |
#include <algorithm> | |
#include <string> | |
using namespace std; | |
int main(){ | |
for( | |
std::istream_iterator<int> iiter(std::cin), eof; | |
++iiter != eof;){ | |
int n = *iiter; | |
if( n < 10 ){ | |
cout << n << endl; | |
} | |
else { | |
std::string result; | |
for(int i = 10 ; --i > 1 ; ) | |
for( ; | |
n % i == 0 ; | |
n /= i, | |
result = ::to_string(i) + result | |
); | |
cout << (n ^ 1 ? -1 : ::stoi(result)) << endl; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
uva product of digits