Maximum operations
Practice
3.3 (49 votes)
Basic programming
Bit manipulation
Bit manipulation
Math
Problem
59% Success 8681 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

The Fibonacci sequence is defined as \(F[n]=F[n-1]+F[n-2]\). You have developed two sequences of numbers. The first sequence that uses the XOR operation instead of the addition method is called the Xoronacci number. It is described as follows:

The second sequence that uses the XNOR operation instead of the addition method is called the XNoronacci number. It is described as follows:

The first and second numbers of the sequence are as follows:

\(X(1)=E(1)=a\\ X(2)=E(2)=b\)

You have also defined the following constraint:

The minimum number of bits that that is used while representing the \(i^{th}\) term must be greater than equal to 3. It must be equal to the minimum number of bits that is required while respresenting the maximum pair (first number, second number) of the respective sequences.

Notes:

Your task is to determine the value of \(max(X(n),E(n))\).

Input format

  • First line: \(t\) denoting the number of test cases
  • Next \(t\) lines: Three integers \(a\), \(b\), and \(n\)

Output format

Print a single integer for each test case.

Constraints

\(1 ≤ T ≤ 10^5\\ 0 ≤ a,\ b,\ n ≤ 10^{12}\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
38 votes
Tags:
Ad-HocApprovedEasyGreatest common divisorMathNumber theorygcd
Points:20
90 votes
Tags:
ApprovedEasyFactorizationMathNumber TheoryOpen
Points:20
207 votes
Tags:
ApprovedEasyMathOpenPrimality testPrime FactorizationReady