Fast Bit Counting

View as PDF

Submit solution

Points: 3 (partial)
Time limit: 0.5s
Memory limit: 64M

Problem type
Allowed languages
C, C++

Given 64-bit unsigned integers, count the bits set in each one.


One function:

int setbits(unsigned long long);

Your function may be called up to 10^8 times.


Your code must be less than 560 characters in length. 560 characters is plenty for any sane solution. Otherwise, only half of the points are awarded.


  • -2
    LennyN  commented on May 31, 2021, 6:33 p.m.

    We should thank and cherish the NSA.

  • 28
    d  commented on April 23, 2020, 2:34 p.m.

    • -12
      wleung_bvg  commented on June 15, 2020, 4:36 p.m.

      This comment is hidden due to too much negative feedback. Show it anyway.