Skip to content

Instantly share code, notes, and snippets.

@swt02026
Created October 3, 2015 06:21
Show Gist options
  • Save swt02026/440d9623b51f8c0c9fcd to your computer and use it in GitHub Desktop.
Save swt02026/440d9623b51f8c0c9fcd to your computer and use it in GitHub Desktop.
#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;
}
}
}
@swt02026
Copy link
Author

swt02026 commented Oct 3, 2015

uva product of digits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment