Given n and k...

Revision en5, by DigiTalDreamar, 2025-07-12 15:47:15

Hello all, Recently I became with a problem that it should be interesting but I did not found any solution except for simulation so I need some help to give me some ideas to solve it.

The problem :

You have two integers n and k, you have n boxes numbered from 1 to n which initially are empty, you should fill them with balls using the given operation :

1 — Choose a box (from 1 to n) and but a ball inside it.

2 — Then for each box i from 1 to n except the chosen box if the parity of the number of balls in the i-th box is as same as the parity of number of balls in the chosen box (after addition in the first step) put a new ball inside it.

Let mx be the maximum number of balls that are contained in a single box, if (mx >= k) then you can not make any more operation.

Given n and k, let x be the number of operations that performed what is the maximum possible value of x ? (The limits of n and k depends on the way of solution which I do not know what is it)

some examples :

3

1 1

2 4

3 3

answer :

1

4

4

explanation :

The first number is the number of test cases.

In the first test case you have 1 box in the first operation you increase it by 1 and you do not have another boxes, the first box contains 1 ball which is equal to k so x is equal to 1.

In the second test the sequence of operations is as follow :

note : for each line there are three arrays the first array represent to the initially positions of boxes, the second is after the first step and the third is after the second step.

{0 , 0} -> {1 , 0} -> {1 , 0} .

{1 , 0} -> {1 , 1} -> {2 , 1} .

{2 , 1} -> {3 , 1} -> {3 , 2} .

{3 , 2} -> {3 , 3} -> {4 , 3} .

The first box containing k boxes so we can not make more operations, it can be shown that this is the maximum value.

In the third test case one possible way to do 4 operations :

{0 , 0 , 0} -> {0 , 1 , 0} -> {0 , 1 , 0} .

{0 , 1 , 0} -> {1 , 1 , 0} -> {1 , 2 , 0} .

{1 , 2 , 0} -> {1 , 2 , 1} -> {2 , 2 , 1} .

{2 , 2 , 1} -> {2 , 2 , 2} -> {3 , 3 , 2} .

you can make 4 operations using another ways but you can not make more than 4 operations in any way.

So this is the problem, what is the best way to solve it and can we print the sequence of possible operations for it and what is the maximum possible limits of n and k ?

please help me and do not forget to give a possible rating and your opinion about it and thank you all ============= in advance.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English DigiTalDreamar 2025-07-12 15:47:48 15 Tiny change: 'nk you all\n============= in advanc' -> 'nk you all in advanc'
en5 English DigiTalDreamar 2025-07-12 15:47:15 15 Tiny change: 'nk you all in advanc' -> 'nk you all\n============= in advanc'
en4 English DigiTalDreamar 2025-07-12 15:24:15 5 Tiny change: 'ine there is three arr' -> 'ine there are three arr'
en3 English DigiTalDreamar 2025-07-12 15:21:05 48
en2 English DigiTalDreamar 2025-07-12 15:18:01 41
en1 English DigiTalDreamar 2025-07-12 15:14:54 2459 Initial revision (published)