Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <algorithm>
- #include <math.h>
- #include<string>
- #include<vector>
- #define pi acos(-1.0)
- #define ll long long int
- #define sc scanf
- #define pf printf
- #define fin for(ll i=0; i<n; i++)
- #define fjm for(ll j=0; j<m; j++)
- #define fr(i,a,n) for(ll i=a; i<n; i++)
- #define rf(i,n,a) for(ll i=n-1; i>=a; i--)
- #define readfirst() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
- using namespace std;
- ll gcd(ll p, ll q) {
- return q==0?p:gcd(q,p%q);
- }
- int main() {
- readfirst();
- ll t, a, b;
- cin >> t;
- while(t--) {
- cin >> a >> b;
- ll x, y;
- if(a==b) {
- x=0;
- y=0;
- }
- else {
- ll mx=max(a,b), mn=min(a,b);
- x=mx-mn;
- if(mn%x==0) y=0;
- else y=min(x-mn%x,mn%x);
- }
- cout << x << " " << y << "\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement