Given a N * N chessboard, the task is to count the number of squares having the odd side length.
Input: N = 3
9 squares are possible whose sides are 1
and a single square with side = 3
9 + 1 = 10
Input: N = 8
Approach: For all odd numbers from 1 to N and then calculate the number of squares that can be formed having that odd side. For the ith side, the count of squares is equal to (N – i + 1)2. Further add all such count of squares.
Below is the implementation of the above approach:
- Number of squares of side length required to cover an N*M rectangle
- Program to find number of squares in a chessboard
- Find the side of the squares which are inclined diagonally and lined in a row
- Find the side of the squares which are lined in a row, and distance between the centers of first and last square is given
- Count Distinct Rectangles in N*N Chessboard
- Minimum and maximum possible length of the third side of a triangle
- Area of a n-sided regular polygon with given side length
- Count pairs (a, b) whose sum of squares is N (a^2 + b^2 = N)
- Count the number of elements which are greater than any of element on right side of an array
- Count number of squares in a rectangle
- Count Magic squares in a grid
- Count number less than N which are product of perfect squares
- Program to count number of distinct Squares and Cubes upto N
- Count the total number of squares that can be visited by Bishop in one move
- Count unique subsequences of length K
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.