In this article, we will solve this problem of the “Two Knights CSES solution “. We will use java language to implement this problem, you can use your preferred language.
Your task is to count for k=1,2,…,n the number of ways two knights can be placed on a k×k chessboard so that they do not attack each other.
Input
The only input line contains an integer n.
Output
Print n integers: the results.
Constraints
- 1≤n≤100001≤n≤10000
Example
Input:8
Output:0
6
28
96
252
550
1056
1848
Two Knights CSES Solution in java
//Two Knights CSES Solution import java.util.*; public class TwoKnights { public static void main(String args[]) { Scanner sc=new Scanner(System.in); long n=sc.nextLong(); for(long i=1;i<=n;i++){ System.out.println((i * i) * (i * i - 1) / 2 - (4 * (i - 2) * (i - 1))); } } } //Two Knights CSES Solution