Even Decimal Binary String
Submissions: 155   Accuracy:

38.72%

  Difficulty: Easy   Marks: 2
     

Given a binary string of size n. you have to count all substring that has even value in its decimal form.

Note: we convert binary String Into decimal from left to right ( 10010:- in Decimal: 9 ).

Input: The first line of input contains an integer T i.e number of the test case. each test case contains n (that is the size of binary string ) and a Binary string of size n.

output: For each test case, In new line print the total count of even binary string.

Constraints:

 1 <= T <= 1000

1<=n<=105

Example :

Input :

2

2

01

5

10010

output :

2

8

Explanation:

Test Case 1 :  substring  are :  0  , 01 , 1  in decimal form : 0 , 2 , 1 so total: 2 even decimal value.

** For More Input/Output Examples Use 'Expected Output' option **

Author: Nishant_Singh


Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.