Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long long f(long long n, int k) {
- ++n;
- vector<int> d;
- while (n > 0) {
- d.push_back(n & 1);
- n >>= 1;
- }
- long long ans = 0;
- for (int i = 0; i < (int) d.size(); i++) {
- if (d[i] == 1) {
- int onesInPrefix = 0;
- for (int j = i + 1; j < (int) d.size(); j++) {
- onesInPrefix += d[j];
- }
- if (onesInPrefix <= k)
- ans += c[i][k - onesInPrefix];
- }
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment