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]: https://www.codechef.com/problems/DARY
[222]: https://www.codechef.com/COHR2018/problems/DARY
[4444]: https://www.codechef.com/users/admin7/
[5555]: https://www.codechef.com/users/admin5/
[333]: https://www.codechef.com/viewsolution/19807212