DARY - Editorial

PROBLEM LINK:

[Practice][111]
[Contest][222]

Author: [admin7][4444]
Tester: [admin5][5555]
Editorialist: [admin7][4444]

DIFFICULTY:

SIMPLE

PREREQUISITES:

Basic Maths

PROBLEM:

You are given a string of length N. In each testcase, you have to find number of substrings of even length for the given string.

EXPLANATION:

You are given a string of length N. The total number of substrings with even length are
(n - 1) + (n - 3) + (n - 5) + … k

Now,

	n + n + n + ....k - (1 + 3 + 5 +........k)


	n * k - $\sum_{i=1}^{k}$ (2 * i) - 1


	(n * k) - (k * k)


	k * (n - k)


			 where k = $\lfloor$n / 2$\rfloor$

AUTHOR’S SOLUTIONS:

Author’s solution can be found [here][333].
[111]: DARY Problem - CodeChef
[222]: CodeChef: Practical coding for everyone
[4444]: admin7 | CodeChef User Profile for Admin | CodeChef
[5555]: admin5 | CodeChef User Profile for Harendra Chhekur | CodeChef
[333]: CodeChef: Practical coding for everyone