Блог пользователя red_coder

Автор red_coder, 14 лет назад, По-английски

suppose we are given two integers M and N such that k1+k2+k3....kM= N

where k1,k2,... are non-negative integers. now we have to print all possible unique combinations along with the numbers of occurence of each combination. for example M= 3 and N=7 so the combinations goes like-

007 3 (3 means 007, 070, 700, 0+0+7=7)

016 6

025 6

034 6

115 3

223 3

...... and so on...

now what is the fastest way to output all the combinations given the integers M and N. M and N can be large...

  • Проголосовать: нравится
  • -49
  • Проголосовать: не нравится

»
14 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

What exactly do you mean by "large"?

»
14 лет назад, скрыть # |
 
Проголосовать: нравится -11 Проголосовать: не нравится

M can be uptu 400 and N can be uptu 800.