ymkzpx

Success and failure are temporary.


  • Home

  • Archives

  • Tags

  • About

判断一个数是否为2的幂

Posted on 2018-07-29 | In ACM

结论:$n$ 是 $2$ 的幂的话 $n\&(n-1)=0$,反之不是。


证明

考虑2的幂的数的二进制位的特点,只有一个1,故n和n-1的二进制位全不一样

# ACM
Codeforces Round 499 (Div. 2)
ZJU 1346 (状压dp)
Kzpx

Kzpx

Hello the cruel world.

215 posts
133 categories
100 tags
GitHub
Links
  • CS-Notes
  • Ali-CsNotes
  • Deadline
  • luowentao
  • biubiubiu
  • Gstnt
  • ecnu
  • Lzy
  • Menci
  • kuangbin
  • meopass
  • tokitsukaze
  • cubercsl
  • Claris
  • hzwer
  • qscqesze
  • ICPCCamp
  • ZYF
  • xehoth
  • Ocean
  • MrBird_to_fly
  • starry_sky
  • Multi-school AC>=20
  • snowy_smile
  • fjzzq2002
© 2019 Kzpx
Powered by Hexo
|
Theme — NexT.Mist v5.1.4