Sunday, 5 October 2014

SPOJ PROBLEM 4343: EMPTY BOXES (EBOXES)

http://www.spoj.com/problems/EBOXES/
 
BRUTE FORCE
MAKE EQUATIONS AND SOLVE IT...

Let intial no. of boxes be N and let X1,X2,...............,X(T) be the no. of selected boxes in T trials

Let K be no. of smaller boxes kept in each larger boxes.

No. of empty boxes would be=:

N -X1 + (K*X1-X2) +   (K*X2-X3)....................+(K*X(T-1)-X(T))+K*X(T)=F

N + K*(X1+X2...........+X(T)) - (X1+X2...........+X(T))=F

(X1+X2............+X(T))=(F-N)/(K-1)

Total no. of boxes would be=:

N+K*(X1+X2...........+X(T))    =>   N+K*((F-N)/(K-1))


1 comment:

  1. sir this line N -X1 + (K*X1-X2) + (K*X2-X3)....................+(K*X(T-1)-X(T))+K*X(T)=F
    I am not able to understand will you please explain it??

    ReplyDelete