Swedish coins (1)

You have a collection CC of nn old Swedish coins. Every coin ii has a probability pip_i of landing heads (and a probability 1pi1 - p_i of landing tails). Consider the following experiment for every subset SS of CC: Flip each coin in SS exactly once, and count the number of heads; you win if this number is odd. Let w(S)w(S) denote the winning probability of the subset SS.

Given two real numbers \ell and rr, and a collection of coins CC, how many subsets SS of CC are such that <w(S)<r\ell < w(S) < r?

Input

Input consists of several cases. Every case begins with two real numbers \ell and rr, followed by nn, followed by p1pnp_1 \dots p_n. Assume 0<<r<10 < \ell < r < 1, 1n401 \le n \le 40 and 0<pi<10 < p_i < 1.

Output

For every case, print the number of subsets SS such that <w(S)<r\ell < w(S) < r. The input cases have no precision issues.

Observation

Please take into account that the result can be larger than 101210^{12}.

Problem information

Author: Salvador Roura

Generation: 2026-01-25T12:07:48.911Z

© Jutge.org, 2006–2026.
https://jutge.org