|  | 
|  | 
| вернуться в форум | Beautiul AC solution Послано Exile  21 сен 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 I don't understand your solution. Can you explaint to me.Re: Beautiul AC solution :) good good. I had the same approach when I read it at first.
 Very easy solution.
Re: Beautiul AC solution Послано J_Leno  5 янв 2008 09:28Very nice, indeed. I wish i had thought of that :)Nevertheless i've solved the problem in my own way :D
 | 
 | 
|