Practice CodeChef: Practical coding for everyone
Contest Contest Page | CodeChef
Editorialist: Arihant singhi arihant95 | CodeChef User Profile for Arihant Singhi | CodeChef
PREREQUISITES:IQ based Maths
PROBLEMFind the Number of sqaures around each block.
EXPLANATIONThe question ask us to calculate the no. of squares around each block..
Following are cases in general :
- If block is at corner .
There will be 3 sqaures around each corner.
- If block is at edge
There will be 5 sqaures around each corner.
General Formula for no. of sqaures around each squares in a grid .
43 + (n-2)(m-2)*8 + (n-2)*10 + (m-2)*10
for grid [n*m]
where n,m >= 2
input test cases
input grid n*m
else if n=1
else if m=1
s=43 + (n-2)(m-2)*8 + (n-2)*10 + (m-2)*10;