Sign in $ create-account
~/problems ~/discussion ~/contests ~/submission
← ~/problems
P2018

Count the Set Bits

Easy
// Description
Count the number of 1-bits in the binary representation of n.
// Input
A single integer n (0 <= n <= 10^18).
// Output
The number of set bits (the population count) of n.
// Hint
Repeatedly clear the lowest set bit, or use a popcount builtin.
// Samples
Sample Input
7
Sample Output
3
// Problem Info
DifficultyEasy
Acceptance50%
Time Limit1000 ms
Memory Limit65536 KB
Accepted5
Bitmasks
// Discussion

No Discussion