You are not logged in. Please login at www.codechef.com to post your questions!

×

CHESS1 - Editorial

PROBLEM LINK:

Practice

Contest

Author: Md Shahid

Tester: Arkapravo Ghosh

Editorialist: Md Shahid

DIFFICULTY:

SIMPLE

PROBLEM:

Given N.You need to find the number of possible squares in N x N chess board.

EXPLANATION:

In this problem you have to count total numbers of all possible squares in the given $N X N$ grid chess.

Total number of square in $1 X 1$ chess = $1$.
Total number of square in $2 X 2$ chess = $5$.
Total number of square in $3 X 3$ chess = $14$.

Can you see a pattern in the above three lines?
Yes.

Total number of square in $1 X 1$ chess = $1$ = $1^2$.
Total number of square in $2 X 2$ chess = $5$ = $1^2$ $+$ $2^2$.
Total number of square in $3 X 3$ chess = $14$ = $1^2$ $+$ $2^2$ $+$ $3^2$.
$.$
$.$
$.$
Total number of squares in $N X N$ chess = $1^2$ $+$ $2^2$ $+$ $3^2$ $+$ $.$ $.$ $.$ $.$ $.$ $.$ $.$ $.$ $+$ $N^2$

As we know from algebra,

$1^2$ $+$ $2^2$ $+$ $3^2$ $+$ $.$ $.$ $.$ $.$ $.$ $.$ $.$ $.$ $+$ $N^2$ = $(N(N+1)(2N+1))/6$

Input N
Sum = (N(N+1)(2N+1))/6
print Sum

AUTHOR'S, TESTER'S AND EDITORIALIST'S SOLUTIONS:

Author's and editorialist’s solution can be found here. Tester's solution can be found here.

Tags:- ENCODING CHESS1 dshahid380

This question is marked "community wiki".

asked 09 Oct, 01:10

dshahid380's gravatar image

3★dshahid380
203
accept rate: 0%

edited 11 Oct, 17:16

admin's gravatar image

0★admin ♦♦
19.5k348496535

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×591

question asked: 09 Oct, 01:10

question was seen: 135 times

last updated: 11 Oct, 17:16