How Do I solve problem ADADIG on spoj?

Revision en2, by Shubham_1007, 2017-09-20 20:59:48

Problem :ADADIG I am trying to solve this , my Approach is: For a given N : 1)If it is prime —> if single digit return 1 else return 0

2)else factorize N and find all combinations of its factor and add 1s to make the digital sum equal to be N and find all permutations of it and add them all and return this. for step 2 , I am unable to figure out How do I do that efficiently?

Tags number theory, spoj adadig, #adhoc

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Shubham_1007 2017-09-20 20:59:48 2 Tiny change: 'return 0\n2)else\n' -> 'return 0\n\n2)else\n'
en1 English Shubham_1007 2017-09-20 20:58:35 454 Initial revision (published)