Binary to Decimal

View as PDF

Points: 10 (p) Time limit: 2.0s Memory limit: 256M Input: stdin Output: stdout

Viết chương trình tính giá trị trong hệ thập phân của một dãy nhị phân cho trước.

Input Specification

Gồm một dãy nhị phân được ghi trên một dòng duy nhất.

Output Specification

In ra kết quả trên một dòng.

Constraints

Dãy nhị phân có độ dài không quá 30.

Input Sample

10101010

Output Sample

170

Explanation for Sample Output

(10101010)₂ = (1 × 2⁷) + (0 × 2⁶) + (1 × 2⁵) + (0 × 2⁴) + (1 × 2³) + (0 × 2²) + (1 × 2¹) + (0 × 2⁰) = (170)₁₀

Comments

There are no comments at the moment.