RAINBOWB - Editorial

C(M,6) where M=(n-1)/2

C(M,6) where M=(n-1)/2

Can you tell me where my reasoning is wrong? For K=7, there is 1 solution: 1…7. for K=8, you can choose any one of [1,7] to clone, so ans=7. *For K=9, you can again choose any one of [1,7] to clone, including one chosen before (for. eg. 1,2,2,2,3,4…), so ans = 7**7. Continuing this way, shouldn’t it be 7^(K-7)?

Could you explain your reasons for believing so?

Can anybody tell if the formula (k-1)C(5) is applicable for k<7 ,because in all these cases answer will come out to be 1.
for example: a1+a2+a3+a4+a5+a6=2 ,here k=2,by using above formula answer will be 1.but in actual it should be 21…please help,any kind of help will be appreciated

for nCr to work n must be greater than equal to r. In your case k-1=1 is less than 5 therefore answer is 0.

1 Like

Dude Awesome !!

why C(K-1,5) ?

It should be 6, right?

@amit001 i think you perhaps misunderstood the solution given in the editorial. As we are brute forcing all the values for 7 so we need to distribute the rest of the values in six containers. agree ??

@kodoos my bad. i was reading solutions in comments so thought 6 should be used but solution above brute force a7. now got it

python nails it.

Why is it not C(k+5,5)?

The link is just for a reference to such kind of equations.

Why is it not C(k+5,5)? http://cseweb.ucsd.edu/classes/wi10/cse20/CSE20%20Lecture%2015.pdf The link is just for a reference to such kind of equations.

awesome!!!

if you are facing problems in implementing the aforesaid algorithm, using C++, you can have a look at my solution:

https://www.codechef.com/viewsolution/16738557

Note: 1. I was completely blown off by this idea (still can’t figure out why) @ma5termind
2. I just figured out that ‘int’ in python has a larger range than ‘long long int’ in C++