ideal opportunity for your very first race in the game against Ronnie. To make the race intriguing, you have wagered a dollars and Ronnie has wagered b dollars. Yet, the fans appear to be frustrated. The fervor of the fans is given by gcd(a,b), where gcd(x,y) means the best normal divisor (GCD) of integers x and y. To make the race seriously invigorating, you can perform two

Operations Research : Applications and Algorithms
4th Edition
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Wayne L. Winston
Chapter17: Markov Chains
Section: Chapter Questions
Problem 12RP
icon
Related questions
Question

Python answer only. Correct answer will upvoted else downvoted.

 

 

It is the ideal opportunity for your very first race in the game against Ronnie. To make the race intriguing, you have wagered a dollars and Ronnie has wagered b dollars. Yet, the fans appear to be frustrated. The fervor of the fans is given by gcd(a,b), where gcd(x,y) means the best normal divisor (GCD) of integers x and y. To make the race seriously invigorating, you can perform two kinds of activities: 

 

Increment both an and b by 1. 

 

Diminishing both an and b by 1. This activity must be performed if both an and b are more noteworthy than 0. 

 

In one action, you can play out any of these activities. You can perform self-assertive (potentially zero) number of moves. Decide the greatest energy the fans can get and the base number of moves needed to accomplish it. 

 

Note that gcd(x,0)=x for any x≥0. 

 

Input 

 

The principal line of input contains a solitary integer t (1≤t≤5⋅103) — the number of experiments. 

 

The first and the main line of each experiment contains two integers an and b (0≤a,b≤1018). 

 

Output 

 

For each experiment, print a solitary line containing two integers. 

 

In the event that the fans can get endless energy, print 0. 

 

Any other way, the main integer should be the greatest energy the fans can get, and the subsequent integer should be the base number of moves needed to accomplish that fervor.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole