Binary to Decimal

4.5

2 votes
Implementation, Easy
Problem

Given a Binary string .
Print an Integer which is Sum of decimal equivalent of every substring.
Since sum will be large print sum modulo  .

Input
A single line consisting of string .

Output
Print an integer answer to the question.

Constraints:

where  denotes the length of string .

Author:  Bibhudhendra Pati

Sample Input
1101
Sample Output
33
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For String S = "1101" all substrings and correspoding decimal values are

[0,0] = "1" = 1
[0,1] = "11" = 3
[0,2] = "110" = 6
[0,3] = "1101" = 13
[1,1] = "1" = 1
[1,2] = "10" = 2
[1,3] = "101" = 5
[2,2] = "0" = 0
[2,3] = "01" = 1
[3,3] = "1" = 1

where [i,j] refers to string from  index to  index 
Sum of all decimal value will be 
1 + 3 + 6 + 13 + 1 + 2 + 5 + 0 + 1 + 1 = 33

Editor Image

?