Advertisement
heian

Untitled

May 22nd, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <inttypes.h>
  4.  
  5. bool VerificaPutere2(int n)
  6. {
  7. int p=1;
  8. while(p<n)
  9. {
  10. p=(p<<1);
  11. }
  12. if(p!=n)
  13. return 0;
  14. return 1;
  15. }
  16.  
  17. int simpatic(unsigned long long x)
  18. {
  19. int i,nrbiti1=0;
  20.  
  21. printf("x = %llu\n", x);
  22.  
  23. for(i=1;i<=64;i++)
  24. {
  25. if((x&1)==1)
  26. nrbiti1++;
  27. x=(x>>1);
  28. }
  29.  
  30. if(VerificaPutere2(nrbiti1))
  31. return 1;
  32. return 0;
  33. }
  34.  
  35. int main()
  36. {
  37. unsigned long long x;
  38. scanf("%llu", &x);
  39. printf("%d", simpatic(x));
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement