HUAWEI OD machine test real questions, 2023B roll machine test question bank full coverage, click here for the guide of brushing the questions
Divide the apple
Knowledge point bit operation base conversion
Time limit: 1s Space limit: 256MB Limited language: unlimited
Title description:
Two people, A and B, divide the apples into two piles. A hopes to divide the apples equally according to his calculation rules. His calculation rules are based on binary addition calculations, and do not calculate the carry 12+5=9 (1100 + 0101=9), The calculation rule of B is decimal addition, including normal carry, and B hopes to obtain the most weight of apples under the condition of satisfying A. Input the number of apples and the weight of each apple, and output the total weight of apples obtained by B when A is satisfied. If the requirement of A cannot be satisfied, output -1.
data range