can someone please help me in this problem??

https://cses.fi/problemset/task/1072

thanks!!

1 Like

+1 i also want to know the same …

from all possibilities of placing two knghts , you can substract those ones in which they both attack each other…(which are 4*(n-1)*(n-2) for given nXn board)

Total possibilities are (n^2)C2

sorry, my fault.

i got ac with (n^2)C2 - 4*(n-1)*(n-2)
can you please explain how did you get this 4*(n-1)*(n-2) term?

thanks!!

```
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
if(i==1)
cout<<0<<"\n";
else if(i==2)
cout<<6<<"\n";
else
{
int p=i*i;
int j=i-2,k=p*(p-1)/2;
k-=8*j*(j+1)/2;
cout<<k<<"\n";
}
}
```

Possible Duplicate: Number of ways two knights can be placed such that they don’t attack

@venturer have shared a link there: Explanation

1 Like

can u please explain??

Hope this will help.

2 Likes