-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExciting_Bets.cpp
More file actions
123 lines (106 loc) · 2.53 KB
/
Exciting_Bets.cpp
File metadata and controls
123 lines (106 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long
#define f(n) for(int i=0;i<n;i++)
#define g(n) for(int j=0;j<n;j++)
#define int long long
#define endl '\n'
int i,j,k;
const int M = 1e9+7;
int arr[200010]={0};
vector<int> a,b,x;
vector<int> v={1,3,6,10,15};
int dx[4]={1,-1,1,-1}, dy[4]={-1,-1,1,1};
bool issquare(int n){
long long low=0,high=n;
long long mid;
while(low<=high){
mid=(low+high)/2;
if(mid*mid==n) return true;
else if(mid*mid<n){
low=mid+1;
}
else high=mid-1;
}
return false;
}
bool iscube(int n){
long long low=0, high=n;
long long mid;
while(low<=high){
mid=(low+high)/2;
if(mid*mid*mid==n) return true;
else if(mid*mid*mid<n){
low=mid+1;
}
else high=mid-1;
}
return false;
}
/*vector<int> bfsOfGraph(int V, vector<int> adj[]) {
int visit[V]={0};
visit[0]=1;
queue<int> q;
q.push(0);
vector<int> bfs;
while(!q.empty()){
int node = q.front();
q.pop();
bfs.push_back(node);
for(auto i:adj[node]){
if(!visit[i]){
q.push(i);
visit[i]=1;
}
}
}
return bfs;
}
void dfs(int node, vector<int> adj[], int vis[], vector<int> &ls){
vis[node]=1;
ls.push_back(node);
for(auto i:adj[node]){
if(!vis[i]) dfs(i,adj,vis,ls);
}
}
vector<int> dfsOfGraph(int V, vector<int> adj[]) {
int vis[V]={0};
int start=0;
vector<int> ls;
dfs(start,adj,vis,ls);
return ls;
}*/
/*bool dfs_cyclecheck(int node, int parent, vector<int> adj[], int vis[]){
vis[node]=1;
for(auto i:adj[node]){
if(!vis[node]){
if(dfs_cyclecheck(i,node,adj,vis)==true) return true;
}
else if(parent!=i){
return true;
}
}
return false;
}*/
void solve(){
int a,b;
cin>>a>>b;
int diff = abs(b-a);
if(diff==0) cout<<0<<" "<<0<<endl;
else if(a%diff==0) cout<<diff<<" "<<0<<endl;
else{
int store = min(a%diff, diff - a%diff);
cout<<diff<<" "<<store<<endl;
}
}
signed main(){
//ifstream in("input.txt");
//ofstream out("output.txt");
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int misery=1;
cin>>misery;
while(misery--) solve();
}