We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
A more intutive ( though lenthier) way is as follows
intmain(){intl,b;cin>>l>>b;intsum4=0;intsum2=0;inttot=0;// this keeps the count of the number of suppliesintprod=l*b;// count the number of 4 blocks ( the largest range i.e 4 blocks = 1 supply )sum4=(l/2)*(b/2);// this gives the number of supplies for 4 unit blocks tot+=sum4;//add the no. of supplies till nowprod-=sum4*4;// deduct the number of blocks taken out sum2=prod/2;// count the number of 2 blocks ( the second largest range i.e 2 blocks = 1 supply )tot+=sum2;prod-=sum2*2;// deduct the number of blocks taken out tot+=prod;// finally add the no of 1's remaining ( 1 block = 1 supply)cout<<tot;// finally print the total number of supplies return0;}
Army Game
You are viewing a single comment's thread. Return to all comments →
A more intutive ( though lenthier) way is as follows