Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <limits.h>
- #include <stdio.h>
- static inline long long min(long long a, long long b)
- { return a < b ? a : b; }
- static inline int floor_log2(long long x)
- { return !x ? -1 : (int) sizeof x * CHAR_BIT - 1 - __builtin_clzll(x); }
- int main(void)
- {
- int T;
- scanf("%d", &T);
- for (int iT = 1; iT <= T; ++iT)
- {
- int N;
- long long P;
- scanf("%d%lld", &N, &P);
- long long may = (1LL << N) - (1LL << N - floor_log2(P));
- long long must = min((1LL << N - floor_log2((1LL << N) - P)) - 2, (1LL << N) - 1);
- printf("Case #%d: %lld %lld\n", iT, must, may);
- }
- }
Add Comment
Please, Sign In to add comment