Minimal Popcount
Practice
5 (3 votes)
Mathematics
Approved
Simple Math
Easy Medium
Mathematics
Mathamatics
Problem
90% Success 1261 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code
Let \(\textrm{pop}(n)\) is number ones n have in binary. For example, \(\textrm{pop}(11) = \textrm{pop}(1011_2) = 3.\)
For integer d, define
\(f(d) = \min_{n \geqslant 0} \textrm{pop}(n \oplus (n + d)).\)
Here \(\oplus\) denotes binary XOR.
You are given d in binary, find \(f(d)\).
Input Format:
Single line contains binary representation of d without leading zeroes.
Output Format:
One integer in decimal numeral system -- \(f(d).\)
Constraints:
\( 1 \leqslant d < 2 ^ {200,000}.\)
50 points
\( 1 \leqslant d < 2 ^ {40}.\)
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
500 votes
Tags:
MathematicsSieveEasy-MediumBinary search algorithmMathematicsMathamatics
Points:30
2 votes
Tags:
Easy-MediumMath
Points:30
9 votes
Tags:
Basic MathAlgorithmsMath
Editorial
Login to unlock the editorial