Pages

Tuesday, May 24, 2011

SPOJ :: PROBOR

Problem Link

type: dynamic programing, probability, expected value.

Solution:
define, dp[i][j][b] = after performing the probabilistic OR on the 0-th to i-th number, what is the probability that, the j-th bit is b.

expected_value = 1*dp[n-1][0][1] + 2*dp[n-1][1][1] + ... 2^k * dp[n-1][k][1] + ...

...hmm, it feels good to be back after a long long break.