Advertisement
pasholnahuy

Untitled

Nov 25th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 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. uint32_t cur = 1;
  10. while (cur != CONST32 && (uint32_t)(1 << cur) < num) {
  11. ++cur;
  12. }
  13. return cur;
  14. }
  15.  
  16. int check(uint32_t num) {
  17. int l = log_2(num);
  18. if (l <= CONST24) {
  19. return 1;
  20. }
  21. if (num % (1 << (l - CONST23)) == 0) {
  22. return 1;
  23. }
  24. return 0;
  25. }
  26.  
  27. int main() {
  28. uint32_t num;
  29. while (scanf("%" SCNx32, &num) == 1) {
  30. printf("%d", check(num));
  31. }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement