bitwise, when we use this ((k >> i) & 1) == 0

Revision en1, by CazadorDivino, 2015-06-18 07:56:43

In the last codeforces 307 div 2, problem D. One solutione is below, What that mean ((k >> i) & 1) == 0.

long pow2 = fastPower(2, n);
        long fib = fibonacci(n + 1);
        long res = 1;
        for (int i = 0; i < l; i++)
            if (((k >> i) & 1) == 0) res = res * fib % mod;
            else
                res = res * (pow2 - fib) % mod;
        if (res < 0) res += mod;
        System.out.println(res);
Tags bitwise

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English CazadorDivino 2015-06-18 07:59:38 47
en2 English CazadorDivino 2015-06-18 07:58:34 131
en1 English CazadorDivino 2015-06-18 07:56:43 491 Initial revision (published)