Vin_add Function

0

0 votes
Implementation, Hard, Greedy
Problem

Today Vin defined a new binary operation named Vin_add for positive integers.

Vin_add is defined as summing two positive integers such that we neglect carry at every step while doing summation.

You are given two positive integers P and Q.

you need to find two integers A ( 0 < A <= P ) and B ( 0 < B <= Q ) such that vin_add is maximum for them.

Your output will be Vin_add( A , B ).

INPUT -

  • First line contains an integer t - number of test cases.
  • Each test case contains two positive integers P and Q .

OUTPUT -

  • For each test case output a single integer containing the answer.

CONSTRAINTS -

  • 0 < t <=100
  • 0 < P , Q <= 10^16
  • 0 < A <= P
  • 0 < B <= Q
  • output should be without leading zeros.
Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?