Search is not available for this dataset
name
stringlengths
2
112
description
stringlengths
29
13k
source
int64
1
7
difficulty
int64
0
25
solution
stringlengths
7
983k
language
stringclasses
4 values
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; public class abc { static long[] inArray(int n,Scanner sc){ long a[]=new long[n]; for (int i = 0; i < n; i++) { a[i]=sc.nextLong(); } return a; } public static int gcd(int a, int b, int x, int y) { // Base Case if (a == 0) ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; public class Main { public static long gcd(long a, long b) { if(b==0) return a; return gcd(b,a%b); } public static void main(String[] args) throws java.io.IOException{ Scanner sc=ne...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> #define inf 100000000 #define int long long #define ll long long #define fr(a,b) for(int i = a; i < b; i++) #define rep(i,a,b) for(int i = a; i < b; i++) #define repn(i,a,b) for(int i = a-1; i >=0; i--) #define prDouble(x) cout << fixed << setprecision(10) << x #define endl "\n" #define yes cout...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import sys def ints(): return list(map(int, sys.stdin.readline().strip().split())) tc = int(input()) while tc: tc-=1 n, m = map(int, input().split()) if abs(n-m) == 0: print(0, 0) continue # elif abs(n-m) == 1: # print(1, 0) # continue print( abs(n-m) , min( ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; import java.lang.Math.*; import java.lang.Math.*; public class solution{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int l = 0;l<t;l++){ long a = sc.nextLong(); long b = sc.nextLong(); ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <iostream> #include<string> #include<algorithm> #include<climits> #include<cmath> #include<vector> #include<map> using namespace std; #define ll long long // void pg() // { // #ifndef ONLINE_JUDGE // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); // #endif // } int main()...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; // problem 1543A - exciting bets public class cf4 { public static void main(String[] args) { Scanner kb = new Scanner(System.in); int num = kb.nextInt(); long a, b, dif, moves; for(int i = 0; i < num; i++) { a = kb.nextLong(); b = kb.nextLong(); dif = Math.abs(a-b); moves...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; #define st first #define nd second #define pb push_back typedef long long ll; typedef pair<int,int> pii; const ll MOD = 1e9 + 7; const int N = 2e5 + 5; int n, t; ll gcd(ll a, ll b){ if(a % b) return gcd(b, a % b); return b; } int main(){ scanf("%d", &t); while(t--)...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
for _ in range(int(input())): a, b = map(int, input().split()) t = abs(a-b) if t==0: print(0,0) else: t2 = min(t-(a%t),a%t) print(t,t2)
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> #include <algorithm> using namespace std; typedef long long ll; /*int gcd(ll n1,ll n2) { return _gcd(n1,n2); } */int main() { #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(false); cin.tie(NULL); ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import sys import math #sys.stdin=open('input.txt','r') #sys.stdout=open('output.txt','w') def solve(): #n=int(input()) a,b=map(int,input().split()) if(a==b): print("0 0") else: r=abs(a-b) #z=max(a,b) if(math.gcd(a,b)==r): print(r,"0") else: ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> // #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure // using namespace __gnu_pbds; //Policy Based Data Structure using namespace std; // typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure /...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; public class ExcitingBets { public static void main(String[] args){ int numberofTest; Scanner sc = new Scanner(System.in); numberofTest = sc.nextInt(); long testCase [][] = new long[numberofTest][2]; for(int i=0; i<numberofTest; i++){ ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
def calc(): a, b = list(map(int, input().split(' '))) if a == b: print('0 0') return d = abs(b - a) x = a % d y = d - x print("{0} {1}".format(d, min([x, y]))) t = int(input()) for _i in range(t): calc()
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
///to serach //n to go forwards N to bakcwards //? to search backwards???? idr //bitwise #include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<long long> #define vpi vector<pair<ll, ll>> #define pb push_back #define pi pair<ll, ll> #define mp make_pair #define mod 4294967295 #define p pai...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
tests=int(input()) for _ in range(tests): a,b=map(int,input().split()) k=abs(a-b) if k==0: print(0,0) else: print(k, min(a%k,k-a%k))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
//Jai Shri Ram //Jai Shri Krishna #include<bits/stdc++.h> using namespace std; #define int long long typedef vector<int> vi ; typedef map<int,int> mii ; typedef pair<int,int> pii ; #define pb push_back #define all(V) V.begin(),V.end() #define uniq(v) (v).erase(unique(all(v)),(v).end()) #define distinct(v) dis...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from math import * t = int(input()) while t != 0: t -= 1 tmp = input().split() a = max(int(tmp[0]), int(tmp[1])) b = min(int(tmp[0]), int(tmp[1])) if a == b: print(0, 0) continue x = a - b y = b - int(b/x)*x w = int(b/x + 1)*x - b print(x, min(y, w))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.HashSet; import java.util.TreeSet; import java.util.Iterator; public class First { public static void main(String[] args) { FastScanner fs = new...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; public class Bets { public static long gcd(long a,long b) { if(b==0) return a; else return gcd(b,a%b); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long a[] = new long[n]; long b[] = new long[n]; for(int i =0;i<n...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import math,sys #sys.stdin=open('input.txt','r') #sys.stdout=open('output.txt','w') def solve(): #print(math.gcd(7,5),"s") n,m=map(int,input().split()) if(n==m): print("0 0") else: diff=abs(n-m) if(n%diff==0): ans=0 else: f=n//diff ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <cstdio> #include <cstring> #include <iostream> #include <set> #include <vector> #include <cmath> #include <map> #include <algorithm> #include <utility> #include <string> #include <cstdlib> #include <queue> #pragma GCC optimize(1) #pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") using namespace...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int t = scanner.nextInt(); while (t-- > 0) { long a = scanner.nextLong(); ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Code written by Aditya ;) || Codechef/codeforces: @adityaraj5200 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ #include<bits/stdc++.h> using namespace std; //#include<ext/pb_ds/assoc_container.hpp> //#include<ext/pb_...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import sys input = sys.stdin.readline for _ in range(int(input())): a, b = map(int,input().split()) if a == b: print(0,0) continue a, b = sorted([a, b]) k = b-a print(k, min(b%k, k-b%k,a))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.awt.image.AreaAveragingScaleFilter; import java.io.*; import java.util.*; import java.lang.*; public class Main{ public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out)); static long MOD = (long) (1e9 + 7); // static long MOD = 998244353; static long MOD2 = M...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.StringReader; import java.lang.reflect.Array; import java.math.BigInteger; import java.text.ParseException; import java.text.SimpleDateFormat; imp...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; #define mod 1000000007 #define ll long long int #define endl "\n" #define pb push_back #define mp make_pair #define ut unsigned int #define ss second #define ff first #define vi vector<int> #define vl vector<ll> #define lb lower_bound #define up upper_bound #define re return...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> #define cs(n) scanf("%d", &n) #define lcs(n) scanf("%lld", &n) #define F(i, j, k) for(int i = j; i <= k; ++i) using namespace std; using ll = long long; const int MAXN = 1000004; const int INF = 0x3f3f3f3f; int main() { int T; cs(T); while(T--) { ll a; lcs(a); ll b; lcs(b); if(a =...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#------------------------template--------------------------# import os import sys import math import collections import functools import itertools # from fractions import * import heapq import bisect from io import BytesIO, IOBase def vsInput(): sys.stdin = open('input.txt', 'r') sys.stdout = open('output.txt',...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from __future__ import division, print_function import os import sys from io import BytesIO, IOBase def main(): pass # region fastio BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = ...
PYTHON
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; #define mp make_pair #define pb push_back #define fi first #define se second #define int long long typedef long long ll; typedef pair<ll, ll> pii; const int N = 2e5 + 10, MOD = 1e9 + 7; int n, m, t, ans, tmp, k1, k2, ans1, ans2; int a[N], b[N]; string s; void read_input() ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
t = int(input()) for _ in range(t): a,b = map(int,input().split()) if a == b: print(0,0) else: ans = abs(a-b) moves = min(b%ans,((-b)%ans + ans)%ans) print(ans,moves)
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import math t = int(input()) for i in range(t): a, b = map(int,input().split()) a, b = max(a, b), min(a, b) if a == b: print("0 0") elif b == 0: print(a, "0") elif b <= a/2: print(a-b, min(b, a-b*2)) else: if a%(a-b) == 0: print(a-b, 0) else: ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class R730_A { public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // public static Scanner br = new Scanner(System.in); public static void main(S...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; import java.lang.Math; public class ExcitingBets{ public static void main(String [] args){ long testCase, a, b, min, a1, c1, a2, c2; long maxEx, minMv; Scanner hero = new Scanner(System.in); //testCase Implimantation testCase = hero.nextLong(); // for testCase for(int...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; using ll = long long; void solve() { ll a, b; cin>>a>>b; if(a == b){ cout<<0<<" "<<0<<"\n"; } else { ll k = max(a, b)-min(a, b); cout<<k<<" "<<min(k-(b%k), b%k)<<"\n"; } } int main() { int t; cin >> t; while (t--) { solve...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int t; cin>>t; while(t--) { int a,b; cin>>a>>b; if(a==b) { cout<<"0 0"<<endl; } else { if(a<b) swap(a,b); int g=a-b; ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; /** * A_Exciting_Bets */ public class A_Exciting_Bets { public static void main(String[] args) { Scanner s = new Scanner(System.in); int t = s.nextInt(); for (int f = 0; f < t; f++) { long a = s.nextLong(); long b = s.nextLong(); ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws java.lang.Exception { Scanner scn=new Scanner(System.in); int t=scn.nextInt(); for(int m=0;m<t;m++){ long a=scn.nextLong(); long b=scn.nextLong(); long diff=Math.abs(a...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import static java.lang.Math.max; import static java.lang.Math.min; import static java.lang.Math.abs; import static java.lang.System.out; import java.util.*; import java.io.*; import java.math.*; public class Template { static int mod = 1000000007; public static void main(String[] args) { FastScanner sc = new Fa...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
# import sys,os,io # input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline PI = 3.141592653589793238460 INF = float('inf') MOD = 1000000007 # MOD = 998244353 def bin32(num): return '{0:032b}'.format(num) def add(x,y): return (x+y)%MOD def sub(x,y): return (x-y+MOD)%MOD def mul(x,y): retur...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class codeforces { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class b729 { public static void main(String[] args) { //System.out.println(1); FastReader sc = new FastReader(); int t = sc.nextInt(); for(int o = 0 ; o<t;o++) { long a = sc.nextLong(); long b...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> #define fi first #define se second #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define mset(x,y) memset(x,y,sizeof(x)) using namespace std; void DBG(){ cerr<<")\n";} template<class H, class... T > void DBG( H h, T... t...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main () { ll tt; cin >> tt; while (tt --) { ll a, b, one, two; cin >> a >> b; if (a == b) { cout << "0 0" << '\n'; continue; } one = abs (a - b); two = min (a % one...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
def main(): A, B = map(int, input().split()) if A == B: return print(0, 0) C = abs(A - B) A %= C print(C, min(A, C - A)) if __name__ == '__main__': T = int(input()) for _ in range(T): main()
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
t = int(input()) for _ in range(t): a, b = map(int, input().split()) if a == b: print(0, 0) else: x = max(a, b) y = min(a, b) print(x - y, min(y % (x - y), x-y - y%(x-y)))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from sys import stdin input = stdin.readline t = int(input()) for _ in range(t): a, b = [int(x) for x in input().split()] d = abs(a - b) if d == 0: print(0, 0) continue minus_count = a % d plus_count = d - minus_count if min(a, b) - minus_count < 0: print(d, plus_count) ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
n = int(input()) for m in range(n): [a, b] = list(map(int, input().split())) if a>b: k = a-b elif a<b: k = b-a else: print("0 0") continue if a%k>k/2: x = k - (a%k) else: x = a%k print(str(k)+" "+str(x))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; public class codeforces1 { public static void main(String args[]) { Scanner sc = new Scanner(System.in); int t; t = sc.nextInt(); while(t>0) { long a, b; a = sc.nextLong(); b = sc.nextLong(); if(a==b) System.out.println(0 + " " + 0); else { long g = M...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
// package com.prituladima; import java.io.*; import java.util.StringTokenizer; /** * Provide prove of correctness before implementation. Implementation can cost a lot of time. * Anti test that prove that it's wrong. * <p> * Do not confuse i j k g indexes. Do extra methods. * <p> * Will program ever exceed limi...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.*; import java.util.Scanner; import java.util.StringTokenizer; public class Problem { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader(){ br = new BufferedReader(new InputStreamReader(System.in)); } ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; typedef long long int ll; void s() { ll a,b; cin>>a>>b; if(a==b) { cout<<"0"<<" "<<"0"; return; } ll dif = abs(a-b); b=min(a,b); if(b%dif==0)cout<<dif<<" "<<"0"; else { ll y = min(b%dif,(dif-b%dif)); co...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <iostream> #include<math.h> using namespace std; int main() { long long int t,x,y; cin>>t; for(int i=0;i<t;++i) { cin>>x>>y; if(x==y) cout<<0<<" "<<0<<endl; else if(abs(x-y)==1) cout<<1<<" "<<0<<endl; else { if(x<y) ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; import java.math.BigInteger; import java.util.*; public class Test2 { public static void main(String[] args) { Scanner in = new Scanner(System.in); int t; t=in.nextInt(); for (int i=0;i<t;i++){ long a,b; a=in.nextLong(); b=in.nextLong(); if (a==0){ System.out.printl...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; #define en "\n"; #define all(x) (x).begin(), (x).end() ll mod = 1000000007; //ull n = 1e8; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll t; cin >> t; //cout<<"as.size()"<<en; ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import sys import math #sys.stdin=open('input.txt','r') #sys.stdout=open('output.txt','w') def solve(): #n=int(input()) a,b=map(int,input().split()) if(a==b): print("0 0") else: r=abs(a-b) z=max(a,b) if(math.gcd(a,b)==r): print(r,"0") else: ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; import java.lang.*; import java.io.*; // Created by @thesupremeone on 07/07/21 public class A { void solve() throws IOException { int ts = getInt(); for (int t = 1; t <= ts; t++){ long a = getLong(); long b = getLong(); long max = Math.max(a, ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
""" Author : Ashish Sasmal Python3 / PyPy3 """ from sys import stdin as sin def aint():return int(input()) def amap():return map(int,sin.readline().split()) def alist():return list(map(int,sin.readline().split())) def astr():return input() from math import gcd,ceil,floor for _ in range(aint()): a,b = ama...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; using lint = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(0); int tc; cin >> tc; while (tc--) { lint a, b; cin >> a >> b; if (a < b) swap(a, b); if (a == b) cout << 0 << " " << 0 << '\n'; else { cout << (a - b) << " " << min(a % (a -...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
def s_a(): t = int(input()) arr = [] for i in range(t): a, b = tuple([int(x) for x in input().split()]) a1, b1 =(a, b) d = abs(a - b) if (d == 0): arr.append("0 0") elif (d == 1): arr.append("1 0") else: i = 0 m = a % d ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
t=int(input()) while t>0: t=t-1 a,b=map(int,input().split()) if a==b: print("0 0") elif a<b: temp=int(b-a) ans=min(a%temp,temp-a%temp) print(temp,ans) else: temp=int(a-b) ans=min(b%temp,temp-b%temp) print(temp,ans)
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int t; scanf("%d",&t); while(t--) { long long a,b,c,d,ans; scanf("%lld%lld",&a,&b); if(a==b) printf("0 0\n"); else { c=abs(a-b); d=a%c; if(d<=c-d) ans=d; else ans=c-d; printf("%lld %lld\n",c,ans); } } ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; const int maxn = 1000 * 100 + 10; int main(){ ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); int t; cin >> t; while (t--){ long long a, b; cin >> a >> b; long long r = abs(a - b); if (!r){ cout << 0 << ' ' << 0 << '\n'; continue; } cout << r <<...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
for a0 in range(int(input())): a,b=[int(x) for x in input().split()] v=abs(a-b) if v==0: print(0,0) else: if a>b: m=b else: m=a v1=m%v if v1>v-v1: v1=v-v1 print(v,v1)
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
//package goldman1; import java.util.*; public class ExcitingBets { public static void main(String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); for(int i=0;i<t;i++){ long a=in.nextLong(); long b=in.nextLong(); if(a==b){ ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
for _ in range(int(input())): a,b=map(int,input().split()) x=min(a,b) y=max(a,b) if x==y: print("0 0") else: print(y-x, end=" ") b=y-x a=x%b print(min(a, b-a))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import os, sys from io import BytesIO, IOBase from types import GeneratorType from bisect import * from collections import defaultdict, deque, Counter import math, string from heapq import * from operator import add from itertools import accumulate BUFSIZE = 8192 sys.setrecursionlimit(10 ** 5) class FastIO(IOBase): ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from math import ceil for i in range(int(input())): a,b=map(int,input().split()) if a==b: print(0,0) else: mgcd=max(a,b)-min(a,b) temp=min(a,b) x=ceil(temp/mgcd) z=temp//mgcd y=(x*mgcd)-temp y2=temp-(z*mgcd) ans=min(temp,y,y2) #print(te...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
//package codeforces; import java.io.*; import java.util.*; public class Solution { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); } String next() { while (st == null || !st.hasMoreElements()) { tr...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
def main(): t = int(input()) # Número de casos for _ in range(t): a, b = map(int, input().split()) # Apuestas de los corredores gcd = abs(a-b) if gcd == 0: print("0 0") else: print(gcd, min(a%gcd, gcd-a%gcd)) ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; public class ExcitingBets { public static void main(String args[]) { Scanner sc=new Scanner(System.in); ExcitingBets it=new ExcitingBets(); int t=sc.nextInt(); while(t--!=0) { long a=sc.nextLong(); long b=sc.nextLong(); long max=Math.abs(a-b); if(a==b) { System.out.pr...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
def excitement(a,b): ans=abs(a-b) diff1=diff2=0 if ans==0: return 0,0 if a%ans!=0: diff1=min((ans-(a%ans)),a%ans) if b%ans!=0: diff2=min((ans-(b%ans)),b%ans) diff=min(diff1,diff2) return ans,diff if __name__ == '__main__': t=int(input()) for _ in range(t): ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#pragma GCC target ("avx2,fma") #pragma GCC optimize ("O3") #pragma GCC optimize ("unroll-loops") #include<bits/stdc++.h> #define int long long #define endl '\n' using namespace std; int IOS = []() {ios::sync_with_stdio(0); std::cin.tie(nullptr); std::cout.tie(nullptr); return 0; }(); #define pb push_back #define po p...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from __future__ import division, print_function import bisect import math import heapq import itertools import sys from collections import deque from atexit import register from collections import Counter from functools import reduce sys.setrecursionlimit(100000) if sys.version_info[0] < 3: from io import BytesIO a...
PYTHON
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while(t--) { long long a,b; cin >> a >> b; if(a==b) cout << 0 << " " << 0 << '\n'; else { long long g = ab...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.*; import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.util.Collections; import java.io.InputStreamReader; import static java.lang.Math.*; import static java.lang.System.*; public class Main1 { public static void main(String[] args) throws IOException {...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; import java.util.StringTokenizer; public class Exiting_bets { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( new Inpu...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
t = int(input()) for _ in range(t): a,b = list(map(int,input().split())) if(a==b): print(0,0) else: max_exi = abs(a-b) min_mov = min(a,b)//max_exi c = abs(min_mov*max_exi - min(a,b)) d = abs((min_mov+1)*max_exi - min(a,b)) print(max_exi,min(c,d)) ...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*; import java.lang.*; import java.io.*; public final class Solution{ public static void main (String[] args) throws Exception { BufferedWriter op = new BufferedWriter(new OutputStreamWriter(System.out)); Reader sc= new Reader(); int t=sc.nextInt(); while...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class A { static FastScanner sc = new FastScanner(); static long gcb(long a,long b){ if(b == 0) return a; return gcb(b,a % b); } static void solve(){ ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; #define ll long long #define FAST1 ios_base::sync_with_stdio(false); #define FAST2 cin.tie(NULL); void solve() { ll a,b; cin>>a>>b; ll ans=abs(a-b); if(ans==0) { cout<<"0 0"; } else cout<<ans<<" "<<min(a%ans,ans-a%ans); } int main(){ FAST1; FAST2; int t; ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import sys import math def read_ints(): inp = input().split() inp = [int(x) for x in inp] return inp def read_strings(): inp = input().split() s = [inp[i] for i in range(len(inp))] return s t = int(input()) for _ in range(t): ab = read_ints() a = ab[0] b = ab[1] maxe = 0 m...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; public class CODECHEF { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader( ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; public class CF1543AExcitingBets { static BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); static PrintWriter output = new PrintWriter(System.out); public s...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> #define ll long long using namespace std; int main(){ ios::sync_with_stdio(false);cout.tie(0);cin.tie(0); int te; cin>>te; while(te--){ ll a,b; cin>>a>>b; if(a<b) swap(a,b); if(a==b){ cout<<"0 0\n"; }else{ ll t=a-b; cout<<t<<' '<<min(b%t,t-b%t)<<'\n'; } } return 0; ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.Scanner; import java.lang.Math; public class Exciting_Bets { static long[] rock(long a, long b){ long out[] = new long[2]; if (a==b){ out[0] = 0; out[1] = 0; return out; } else if (Math.abs(a-b)==1){ out[0] = 1; ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.util.*;import java.io.*;import java.math.*; public class CF1543A { static boolean memory = true; static long mod = 998244353; static long MOD = 1000000007; static void ruffleSort(int[] a) { int n = a.length; ArrayList<Integer> lst = new ArrayList<>(); for(int i ...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
aa=int(input()) for i in range(aa): temp=0 x,y=map(int,input().split()) if(x<y): temp=x x=y y=temp if(x==y): print('0 0') continue else: g_c_d= abs(x-y) z=x%g_c_d mini=min(z,g_c_d-z) print(g_c_d,mini)
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <stdio.h> int main() { int t; scanf("%d", &t); while(t--) { long long int a, b; scanf("%lld", &a); scanf("%lld", &b); if(a == 0) { printf("%lld 0\n", b); }else if(b==0) { printf("%lld 0\n", a); }e...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; int main() { long long t; cin >> t; long long otv[t][2]; for (long long i=0; i<t; i++) { long long a,b; cin >> a >> b; if (a==b) { otv[i][0]=0; otv[i][1]=0; } else { if (a>b) { long long v=a; a=b; b=v; } long long ra...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include<bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ long long int a,b; cin>>a>>b; long long int diff = abs(a-b); long long int moves = 0; if(a==b) cout<<0<<" "<<0<<"\n"; else{ if(a>diff) moves = a%diff; ...
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
""" from sys import stdin, stdout import math from functools import reduce import statistics import numpy as np import itertools import operator from sys import stdin, stdout import math from functools import reduce import statistics import numpy as np import itertools import sys import operator from collections import...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
t = int(input()) ans = [] for i in range(t): ip = input() ip = ip.split(' ') x,y = int(ip[0]), int(ip[1]) x1,y1 = x,y gcd = abs(x-y) if gcd == 0: ans.append('{} {}'.format(0,0)) continue c = 0 mul = int(x/gcd) ans.append('{} {}'.format(gcd,min(abs(gcd*mul-x),abs(gcd*(mul+1)-x)))) for i in range(t): print...
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.util.Scanner; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelpe...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
from math import gcd for _ in range(int(input())): a, b = (map(int, input().split())) if a == b: print(0, 0) else: diff = abs(a - b) ans1 = min(a, b) % diff ans2 = diff - min(a, b) % diff print(diff, min(ans1, ans2))
PYTHON3
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import java.io.*; import java.util.*; public class A { public static void main(String[] args) throws NumberFormatException, IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputS...
JAVA
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
#include <bits/stdc++.h> using namespace std; int main(){ int t; cin>>t; while(t--){ long long a, b; cin>>a>>b; if(a==b){ cout<<0<<' '<<0<<endl; }else{ long long c=abs(a-b); long long d=min(a%c, c-a%c); cout<<c<<' '<<d<<endl; } } }
CPP
1543_A. Exciting Bets
Welcome to Rockport City! It is time for your first ever race in the game against Ronnie. To make the race interesting, you have bet a dollars and Ronnie has bet b dollars. But the fans seem to be disappointed. The excitement of the fans is given by gcd(a,b), where gcd(x, y) denotes the [greatest common divisor (GCD)]...
2
7
import random import collections import string import math import copy import os import sys from io import BytesIO, IOBase BUFSIZE = 8192 class FastIO(IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = BytesIO() self.writable = "x" in file.mode or ...
PYTHON3