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] Divisible by 3 CodeChef Solution | CodeChef Problem Solution 2022

Stack likes the number 3 a lot.

He has two non-negative integers A and B.
In one operation, Stack can do either of the following:

  • A:=|AB| (change A to |AB|)
  • B:=|AB| (change B to |AB|)

Note that |X| denotes absolute value of X. For example |7|=7 and |4|=4.

Find the minimum number of operations after which at least one integer out of A 

Solution Click Below:-  CLICK HERE


and B becomes divisible by 3.

Input Format

  • The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
  • The only line of each test case contains two integers A and B.

Output Format

For each test case, output in a single line the minimum number of operations after which at least one integer out of A and B becomes divisible by 3.

Constraints

  • 1T105

No comments:

Post a Comment