Divide Candies SOLUTION

There are N piles of confections (numbered 1 through N); for each legitimate I, the I-th of them contains precisely iK confections. You plan to parcel these loads among you and your companion so that each store is given to precisely one of you without being part among you. 
The conveyance ought to be as reasonable as could be expected under the circumstances. Officially, how about we signify the all out number of confections you get by An and the all out number of confections your companion gets by B; you will probably limit |A−B|. 
Locate the littlest conceivable estimation of |A−B| and dole out the piles to you and your companion somehow or another that limits |A−B|. On the off chance that there are different arrangements, you may locate any of them. 
The primary line of the information contains a solitary number K, which is basic for all experiments. 
The subsequent line contains a solitary number T signifying the quantity of experiments. The depiction of T experiments follows. 
The solitary line of each experiment contains a solitary number N. 
For each experiment, print two lines. 
The first of these lines ought to contain a solitary number ― the littlest estimation of |A−B| we can acquire. 
The subsequent line ought to contain N characters depicting your task of stacks. For each legitimate I, the I-th of them ought to be ‘1’ in the event that you need to give the I-th load to you or ‘0’ in the event that you need to offer it to your companion. 
the whole of N over all experiments doesn’t surpass 5⋅106 
Subtask #1 (5 focuses): K=1 
Subtask #2 (10 focuses): K=2 
Subtask #3 (15 focuses): K=3 
Subtask #4 (70 focuses): K=4 
Model Input 1 
Model Output 1 
Model case 1: There are four piles with sizes 1, 4, 9 and 16 and two ideal tasks: either give the last pile to yourself and the rest to your companion or the other way around (so both “0001” and “1110” would be viewed as right yields). In the two cases, |A−B|=|16−(1+4+9)|=2. 
Model case 2: There are five piles with sizes 1, 4, 9, 16 and 25. You can dole out the second and fifth stack to yourself, and in this manner |A−B|=|(25+4)−(16+9+1)|=3. It very well may be demonstrated this is the littlest conceivable estimation of |A−B|. 
Model Input 2 
Model Output 2 
Model case 3: We have K=4 and N=9. The littlest estimation of |A−B| is |(64+74+84)−(14+24+34+44+54+94)|=|7793−7540|=253.

8 thoughts on “Divide Candies SOLUTIONS EQDIV”

  1. bro code leke kya karoge be cheating kar ke tum log pura contest ko bar baad kar diyo ho atleast yah log code toh nahi de rahe hai na kam se kam logic toh explain kar hi rahe h yah log jo yah cheating se jada bahtar h

    Hey do not share the code but please share the logic as you have did for other questions looking forward to it.


Leave a Comment

18 − thirteen =