TaroCoins
SRM 631 · 2014-07-26 · by Witaliy
Problem Statement
Cat Taro likes coins. For any non-negative integer K, he has exactly two coins of value 2^K (i.e., two to the power of K).
You are given a
Notes
- The answer will always fit in a signed 64-bit integer.
Constraints
- N will be between 1 and 1,000,000,000,000,000,000 (10^18), inclusive.
1 Returns: 1
The only possible way to represent N in this case is to use one coin of value 1.
6 Returns: 3
The following three representations are possible in this case: {1, 1, 2, 2}, {1, 1, 4} and {2, 4}
47 Returns: 2
256 Returns: 9
8489289 Returns: 6853
Submissions are judged against all 63 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class TaroCoins with a public method long long getNumber(long long N) · 63 test cases · 2 s / 256 MB per case