ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1014. Product of Digits

Beautiul AC solution
Posted by Exile 21 Sep 2005 22:43
#include <iostream.h>

bool next(unsigned long int n)
{
        for (unsigned short int i=9;i>1;i--)
            if (n%i==0&&(n/i>9?next(n/i):i+=n/i*10))
            {
                cout << i;
                return 1;
            }
        return 0;
}

int main()
{
   unsigned long int n;
   cin >> n;
   if (n<10)
       cout << (n==0?10:n);
   else
       if (!next(n))
           cout << -1;
   return 0;
}

Do you like it as much as i do? :)
Re: Beautiul AC solution
Posted by hailoc12 28 Sep 2006 20:44
I don't understand your solution. Can you explaint to me.
Re: Beautiul AC solution
Posted by Zhihua Lai 29 Jan 2007 19:51
:) good good. I had the same approach when I read it at first.

Very easy solution.
Re: Beautiul AC solution
Posted by J_Leno 5 Jan 2008 09:28
Very nice, indeed. I wish i had thought of that :)
Nevertheless i've solved the problem in my own way :D