A
A
Anton B2014-07-10 17:40:30
PHP
Anton B, 2014-07-10 17:40:30

How to make all possible combinations of placing 10 apples on 21 plates?

Good afternoon.
There are 21 plates and 10 apples. How to make all possible combinations of placing apples on plates?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
Perzh, 2014-07-10
@bigton

Do you need to count the number or just go through all the combinations?

I
Ivan Ivanov, 2014-07-10
@Csklassami

Where n is the total number of elements, and k is a group from this set. In addition to the function of finding the factorial and the arithmetic operations of the initial classes, nothing is needed.
4991c0fdf2a7431fa545bd3815536575.JPG

R
Rsa97, 2014-07-11
@Rsa97

The condition is incomplete. Are apples considered unique or the same? What is the maximum number of apples that can be on one plate?

M
Mrrl, 2014-07-18
@Mrl

In C it would look like this:

int k=21,m=10,s,h;
  for(s=(1<<m)-1;s<(1<<k);){
    printf("%x ",s);
    h=s&-s;
    s+=h;
    s+=(s&-s)/(2*h)-1;
  }
  printf("\n");

Numbers are printed, the ones in the binary representation of which form a mask of occupied plates.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question