4fd800b3a8 2011-02-23 kinaba: struct ProductOfDigits 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: int smallestNumber( int N ) 4fd800b3a8 2011-02-23 kinaba: { 4fd800b3a8 2011-02-23 kinaba: if( N < 10 ) 4fd800b3a8 2011-02-23 kinaba: return 1; 4fd800b3a8 2011-02-23 kinaba: int ans = 0; 4fd800b3a8 2011-02-23 kinaba: for(int d=9; d>=2; --d) 4fd800b3a8 2011-02-23 kinaba: while( N%d == 0 ) 4fd800b3a8 2011-02-23 kinaba: N/=d, ans++; 4fd800b3a8 2011-02-23 kinaba: return N==1 ? ans : -1; 4fd800b3a8 2011-02-23 kinaba: } 4fd800b3a8 2011-02-23 kinaba: };