Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long long f(long long n, int k) {
- ++n;
- int bits = __builtin_popcountll(n);
- int cur = 0;
- long long ans = 0;
- while (n > 0) {
- if ((n & 1) == 1) {
- --bits;
- if (k >= bits)
- ans += c[cur][k - bits];
- }
- n >>= 1;
- ++cur;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment