R.A.X's blog

By R.A.X, 10 years ago, In English

I am unable to solve this problem http://codeforces.com/contest/441/problem/E .Can you guys provide me with some hints?

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
10 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it
  • »
    »
    10 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    I tried reading the editorial but I am not getting it (may be it is too advance !). But I found that some people solved the problem in few lines can you explain the dp states
    p: is the probability of getting number smaller than p ~~~~~

    for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= n; ++j)
    if (!i)
    for (int a = x + j; !(a & 1); ++f[i][j], a >>= 1);
    else
    {
    f[i][j] += f[i — 1][j + 1] * (1.0 — p);
    if (!(j & 1))
    f[i][j] += (f[i — 1][j / 2] + 1) * p;
    }

    ~~~~~