Coin Toss

Xem PDF

Điểm: 400 Thời gian: 1.0s Bộ nhớ: 256M Input: bàn phím Output: màn hình

A sequence of coin toss can be encoded as a binary string, ’0’ for head, ’1’ for tail. Given an encoded sequence \(S\),
toss the coin until \(S\) appears in the result sequence then stop.
Let \(T\) be the number of coin toss taken for \(S\) to appear, find the expected value of \(T\).

Input

Let \(T\) be the number of coin toss taken for \(S\) to appear, find the expected value of \(T\).

Output

Let \(T\) be the number of coin toss taken for \(S\) to appear, find the expected value of \(T\).

Example

Test 1

Input
1
00
Output
6

Bình luận

Không có bình luận nào.