How many T-shirts will be sent?
I think problems werenât hard this time but a lot trickier, even though I could solve only 2 problems (VCAKE and COLTREE) , in COLTREE only n and k were required and not the structure of the tree.
I think solutions of first 4 problems wonât be more than 10 lines of code.
Can you please explain 2nd problem, could not get it even now, what I understood was, you are given sum of A.P and number of terms in the A.P and you want to know whether a positive integer A.P exists or not with such property.
Well, you want to solve Nx+d*(N-1)*N/2 = C where x and d >=1, u have 2 cases if N is even or odd
Could you describe the approach for VCAKE plz?
Initially I subtracted n*(n+1)/2 from C to ensure that each get atleast one with common difference>=1. But still got WA. Dont know why 
You must agree that following conditions should hold:
- R*C = M + K + J
- One piece should have one of the dimension as R or C (think about it)
- Then you are left with a reduced cake with dimensions (X) * (Xâ - Z/X), (X = R or C, Xâ = C or R, Z = M or K or J, resp.), then apply same process as in 1 and 2 for 2 pieces.
My solution link : 5TGjIZ - Online C++ Compiler & Debugging Tool - Ideone.com
right, couldnât proceed further or had some bugs in my code, could you please share your code.
I guess weâd have to wait till they publish the editorials. The submissions arenât public as yet.
try this
4 8
Thanks. About COLTREE i implemented nCr and factorial discarding tree structure but I got WA. What was your approach?
For second one you need to make sure that the solution to ax + by = c has positive values for a and b. You can solve that by modifying the linear diophantine.
What was the approach for the third one ? I skipped that and did the 4th instead as I couldnât make any progress and eventually had to move on.
How you solved the 4th one?
@thezodiac1994. i tried a lot, can you give link to your solution if did using linear diophantine way? My solution link: CodeChef: Practical coding for everyone
What is your approach to find the sum closest to sum/2. I tried the standard dp but got tle and couldnât fix it until the end of contest. 
@pranavarora - simple subset sum solution - for(i=0; i<n; i++) { for(j=MAX; j>=a[i]; jâ) possible[j] |= possible[j-a[i]] }
If you donât mind, can you please share the code?
- make a set of east west moves. call sum of this set as sum1.
- make a set of north south moves. sum of this set = sum2.
- find closest sum of subsets to sum1/2 and sum2/2 in sets 1 and 2 and add them.