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. Algorithms
  3. Search
  4. Beautiful Quadruples

Beautiful Quadruples

Problem
Submissions
Leaderboard
Discussions
Editorial

We call an quadruple of positive integers, , beautiful if the following condition is true:

Note: is the bitwise XOR operator.

Given , , , and , count the number of beautiful quadruples of the form where the following constraints hold:

When you count the number of beautiful quadruples, you should consider two quadruples as same if the following are true:

  • They contain same integers.
  • Number of times each integers occur in the quadruple is same.

For example and should be considered as same.

Input Format

A single line with four space-separated integers describing the respective values of , , , and .

Constraints

  • For of the maximum score,

Output Format

Print the number of beautiful quadruples.

Sample Input

1 2 3 4

Sample Output

11

Explanation

There are beautiful quadruples for this input:

Thus, we print as our output.

Note that is same as .

Author

zxqfd555

Difficulty

Medium

Max Score

50

Submitted By

3879

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

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