Advertisement
pasholnahuy

Untitled

Nov 25th, 2023
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. #include <ctype.h>
  2. #include <float.h>
  3. #include <inttypes.h>
  4. #include <stdio.h>
  5.  
  6. enum { CONST32 = 32, CONST24 = 24, CONST23 = 23 };
  7.  
  8. int log_2(uint32_t num) {
  9. int cur = 0;
  10. while (cur != CONST32 && (uint32_t)(1 << cur) <= num) {
  11. ++cur;
  12. }
  13. // printf("%d\n", cur - 1);
  14. return cur - 1;
  15. }
  16.  
  17. int check(uint32_t num) {
  18. int l = log_2(num);
  19. if (l <= CONST23) {
  20. return 1;
  21. }
  22. if (num % (1 << (l - CONST23)) == 0) {
  23. return 1;
  24. }
  25. return 0;
  26. }
  27.  
  28. int main() {
  29. uint32_t num;
  30. while (scanf("%u", &num) == 1) {
  31. printf("%d\n", check(num));
  32. }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement