#C12853. Binary to Decimal Conversion

    ID: 42326 Type: Default 1000ms 256MiB

Binary to Decimal Conversion

Binary to Decimal Conversion

Given a binary string, your task is to convert it into its decimal equivalent.

The input will be a string containing only the characters '0' and '1' (up to 16 characters). The binary number may include leading zeros. If the input is empty or contains any character other than '0' or '1', your program should output an error message.

You can use the formula: $$\text{decimal} = \sum_{i=0}^{n-1} b_i\times2^{n-1-i}$$, where \(b_i\) is the i-th digit of the binary string and \(n\) is the length of the string.

Make sure to read the input from stdin and write the result to stdout.

inputFormat

The input consists of a single line containing a binary string. The string should have at most 16 characters.

outputFormat

If the input is a valid binary string, output the decimal conversion of the binary number.

If the input is invalid (empty or containing characters other than '0' and '1'), output:

Error: Invalid input
## sample
1010
10