We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. C++
  3. Other Concepts
  4. C++ Variadics

C++ Variadics

Problem
Submissions
Leaderboard
Discussions
Editorial

A template parameter pack is a template parameter that accepts zero or more template arguments (non-types, types, or templates). To read more about parameter pack, click here.

Create a template function named reversed_binary_value. It must take an arbitrary number of bool values as template parameters. These booleans represent binary digits in reverse order. Your function must return an integer corresponding to the binary value of the digits represented by the booleans. For example: reversed_binary_value<0,0,1>() should return .

Input Format

The first line contains an integer, , the number of test cases. Each of the subsequent lines contains a test case. A test case is described as space-separated integers, and , respectively.

  • is the value to compare against.
  • represents the range to compare: to .

Constraints

  • The number of template parameters passed to reversed_binary_value will be .

Output Format

Each line of output contains binary characters (i.e., 's and 's). Each character represents one value in the range. The first character corresponds to the first value in the range. The last character corresponds to the last value in the range. The character is if the value in the range matches ; otherwise, the character is .

Sample Input

2
65 1
10 0

Sample Output

0100000000000000000000000000000000000000000000000000000000000000
0000000000100000000000000000000000000000000000000000000000000000

Explanation

The second character on the first line is a , because the second value in the range is and is .

The eleventh character on the second line is a , because the eleventh value in the range is and is .

All other characters are zero, because the corresponding values in the range do not match .

Author

vcato

Difficulty

Hard

Max Score

80

Submitted By

20280

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature