MOZSABN - Sharmeen and binary number
Sharmeen, the little girl learned about binary numbers recently. But she is unable to handle it, if the number becomes large. Her friend Mozahid gave her a task to find the number of set bits in a given binary bumber. As the number can be very large, she can’t cope with the solution of this problem. As a programmer, it’s your duty to help her.
A binary number is a number which contains only ‘0’ and ‘1’. Set bit means the bit which have the value ‘1’. For example a binary number ‘1011’ has 3 set bits.
It can contain leading zeros.
Input
Given a large binary number of length n. It can have at most 105 digits.
Output
Output the number of set bits in the binary number.
Example
Input: 1011 Output: 3
Added by: | Mozahid |
Date: | 2019-09-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |