Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <float.h>
- #include <inttypes.h>
- #include <stdio.h>
- enum { CONST32 = 32, CONST24 = 24, CONST23 = 23 };
- int log_2(uint32_t num) {
- int cur = 0;
- while (cur != CONST32 && (uint32_t)(1 << cur) <= num) {
- ++cur;
- }
- printf("%d\n", cur - 1);
- return cur - 1;
- }
- int check(uint32_t num) {
- int l = log_2(num);
- if (l <= CONST23) {
- return 1;
- }
- if (num % (1 << (l - CONST23)) == 0) {
- return 1;
- }
- return 0;
- }
- int main() {
- uint32_t num;
- while (scanf("%u", &num) == 1) {
- printf("%d\n", check(num));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement