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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education