# Black cells in a chessboard Codechef Solution

Dec 20, 2022

Hello Programmers In this post, you will know how to solve the Black cells in a chessboard Codechef Solution.

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.

### Problem

Given nn (nn is even), determine the number of black cells in an n×nn×n chessboard.

### Input Format

The only line of the input contains a single integer nn.

### Output Format

Output the number of black cells in an n×nn×n chessboard.

### Constraints

• 2≤n≤1002≤n≤100
• nn is even

```8
```

```32
```

### Explanation

There are 3232 black cells and 3232 white cells in an 8×88×8 chessboard. So the answer is 3232.

### Black cells in a chessboard CodeChef Solutions in JAVA

```import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
if(a%2==0)
{
int b=(a*a)/2;
System.out.println(b);
}
}
}```

### Black cells in a chessboard CodeChef Solutions in CPP

```#include <iostream>
using namespace std;
int main() {
int n, a, b;
cin >> n;
a = n * n;
b = a / 2;
cout << b;
return 0;
}```

### Black cells in a chessboard CodeChef Solutions in Python

```n=int(input())
print((n*n)//2)```

Disclaimer: The above Problem (Black cells in a chessboard) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purposes.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.