|
|
back to boardVery simple!!!!! Greedy algo! #include <iostream> #include <set> using namespace std; int main() {multiset<int> ms; int i, n; cin>>n; if(n==0) {cout<<10; return 0;} if(n==1) {cout<<1; return 0;} for(i=9; i>=2; i--) while(n%i==0) {ms.insert(i); n/=i; } if(n>1) {cout<<-1; return 0;} else for(multiset<int>::iterator it=ms.begin(); it!=ms.end(); it++) cout<<*it; return 0; } //--------------------------------------------------------------------------- Edited by author 08.11.2008 01:39 |
|
|