### PROBLEM LINK

Practice CodeChef: Practical coding for everyone

Contest Contest Page | CodeChef

**Editorialist:** Arihant singhi arihant95 | CodeChef User Profile for Arihant Singhi | CodeChef

### DIFFICULTY:

Simple### PREREQUISITES:

IQ based Maths### PROBLEM

Find the Number of sqaures around each block.### EXPLANATION

The 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 .

4*3 + (n-2)*(m-2)*8 + (n-2)*10 + (m-2)*10

for grid [n*m]

where n,m >= 2

pseudocode

Start

input test cases

input grid n*m

if n=m=1

print 0;

else if n=1

s= (m-2)*2+2

else if m=1

s= (n-2)*2+2

else

s=4*3 + (n-2)*(m-2)*8 + (n-2)*10 + (m-2)*10;

print s;

End