Advertisement
greannmhar

бинарные 10

Nov 29th, 2023
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.37 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int sol(int n);
  4. int sol(int n)
  5. {
  6.     return !(n & (n - 1)) && (n % 3 == 1);
  7. }
  8.  
  9. int main(void)
  10. {
  11.     int n;
  12.     if (scanf("%d", &n) != 1)
  13.     {
  14.         printf("cannot read n!\n");
  15.     }
  16.  
  17.     if (sol(n)) {
  18.         printf("is a power of 4\n", &n);
  19.     }
  20.     else {
  21.         printf("is not a power of 4\n", &n);
  22.     }
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement