GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Wednesday, 8 June 2022

[Solution] Maximise Set Bits CodeChef Solution | CodeChef Problem Solution 2022

Let f(X) denote the number of set bits in X.

Given integers N and K, construct an array A of length N such that:

  • 0AiK for all (1iN);
  • i=1NAi=K

Over all such possible arrays, find the maximum value of i=1Nf(Ai).

Input Format

  • The first line of input contains a single integer T - the number of test cases. The description of T test cases follow.
Solution Click Below:-  CLICK HERE


  • The only line of each test case contains integers N and K- the length of the array and sum of elements respectively.

Output Format

For each test case, output the maximum value of i=1Nf(Ai).









Constraints

  • 1T104
  • 1N109

No comments:

Post a Comment