prompt string | response string |
|---|---|
Problem: 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 divis... | import math
n=int(input())
for g in range(n):
a,b=map(int,input().split())
diff=abs(a-b)
x=min(a,b)
if a==b:
print(0,0)
else:
y=x%diff
z=min(y,diff-y)
print(diff,z) |
Problem: 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 divis... | /*package whatever //do not write package name here */
import java.util.*;
public class GFG {
public static void main (String[] args) {
Scanner scan=new Scanner(System.in);
int n=scan.nextInt();
while(n!=0)
{ long diff=0;
long count =0;
long ans=0;
long a=scan... |
Problem: 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 divis... | #include <iostream>
#include <math.h>
#include <algorithm>
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 exc = abs(a-b);
long long num = min(a%exc, exc - a%exc);
... |
Problem: 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 divis... |
import java.io.*;
import java.util.*;
public class test3 {
static long MOD = (int)1e9 +7;
static long mod(long n) {
return (n%MOD +MOD)%MOD;
}
public static void main(String[] args) throws IOException {
FastReader f = new FastReader();
int t = f.nextInt();
while(t-->0) {
long a ... |
Problem: 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 divis... |
import java.util.*;
import java.io.*;
public class CodeChef{
public static void main(String[] args) {
FastReader in = new FastReader();
int t = in.nextInt();
while(t-->0) {
long a = in.nextLong();
long b = in.nextLong();
if(a-b==0) System.out.println(0+" "+0);
else {
long count =0;
long... |
Problem: 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 divis... | from sys import stdin, stdout
def arrin():
return list(map(int, stdin.readline().split()))
def num1in():
return int(stdin.readline())
def num2in():
a, b = map(int, stdin.readline().split())
return a, b
def num3in():
a, b, c = map(int, stdin.readline().split())
return a, b, c
def num4in():
a,... |
Problem: 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 divis... | import java.math.*;
import java.util.*;
public class Main
{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args)
{
int t = sc.nextInt();
while (t-- > 0)
{
long a=sc.nextLong();
long b=sc.nextLong();
long c;
if(a<b){
c=a;
a=b;
b=c;
}
if(a==b) System... |
Problem: 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 divis... | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PB push_back
#define MP make_pair
#define PPB pop_back
int gcd(int a, int b){
if(b==0)
return a;
return gcd(b,a%b);
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t=1;
cin>>... |
Problem: 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 divis... | import java.io.*;
import java.util.*;
public class Main
{
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStrea... |
Problem: 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 divis... | #include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007
// void func(){
// }
void solution(){
ll a,b; cin>>a>>b;
ll val = abs(a-b);
if(val==0){
cout<<"0 0"<<endl;
return;
... |
Problem: 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 divis... | import java.util.*;
public class ExcitingBets {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
long T = sc.nextLong();
//sc.nextLong();
for(int t=0;t<T;t++) {
long a = sc.nextLong();
long b = sc.nextLong();
if(a==b) {
System.out.... |
Problem: 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 divis... | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
// freopen("file.in", "r", stdin);
int t;
cin >> t;
while(t--){
ll a, b;
cin>>a>>b;
if(a == b) {
cout<<0<<' '<<0<<'\n';
continue;
}
cout<<abs(a-b)<<' ';
... |
Problem: 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 divis... | import java.util.*;
public class Div2_730A {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
long a=sc.nextLong();
long b=sc.nextLong();
long gcd=Math.abs(a-b);
if(a>b){
... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
const int N=100200;
typedef long long ll;
int main(){
ll t;
ll a, b, k, mi;
cin>>t;
while(t--){
cin>>a>>b;
if(b>a)swap(a,b);
if(a==b)cout<<"0 0"<<endl;
else{
k=a-b;
mi=min(a%k,k-a%k);
cout<... |
Problem: 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 divis... | def main():
test = int(input())
for _ in range(test):
a, b = map(int, input().split())
if a == b:
print("0 0")
continue
if a > b:
a, b = b, a
diff = abs(a - b)
if b % diff == 0:
print(f"{diff} {0}")
continue
... |
Problem: 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 divis... | t = int(input(""))
import math
i , it, a,b = 0,0, t*[0], t*[0]
while i<t:
a[i], b[i] = map(int, input().split())
i += 1
for i in range(0,t):
diff = abs(a[i] - b[i])
if diff != 0:
lol = a[i] % diff
if lol < diff/2:
print(diff, lol)
else:
print(diff, diff -... |
Problem: 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 divis... | t=int(input())
for _ in range(t):
x,y=[int(x) for x in input().split(' ')]
a,b=min(x,y),max(x,y)
if b==a:
print(0,0)
elif a*b==0:
print(b,0)
else:
print(b-a,min(a%(b-a),b-a-a%(b-a))) |
Problem: 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 divis... | #include<bits/stdc++.h>
#define int long long
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define fr(a,b) for(int i = a; i < b; i++)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)... |
Problem: 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 divis... | import math
import sys
input = sys.stdin.readline
#Ceil check function
def chk(p, a):
if p % a == 0:
return 0
return 1
for _ in range(int(input())):
a,b = map(int,input().split())
if a == b:
sys.stdout.write(str(0)+" "+str(0)+"\n")
continue
ans = max(a,b)-min(a,b)
num... |
Problem: 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 divis... | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import ja... |
Problem: 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 divis... | import math
d=int(input())
for p in range(0,d):
m=0
n=0
a,b= list(map(int, input().split()))
if a==b:
print(0,0)
continue
x=math.gcd(a,b)
if a>b:
l=(a-b)
else:
l=(b-a)
if x==l:
print(x,0)
continue
q=a%l
w=l-q
print(l,min(q,w)) |
Problem: 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 divis... | kol = int(input())
for i in range(kol):
a, b = [int(i) for i in input().split()]
if a == b:
print(0, 0)
else:
g = abs(a - b)
m = min(a % g, g - a % g)
print(g, m) |
Problem: 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 divis... | #!/usr/bin/env python
from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def main():
t = int(input())
for _ in range(t):... |
Problem: 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 divis... |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t;
cin>>t;
while(t--){
ll n,k;
cin>>n>>k;
if(abs(n-k)==0){
cout<<0<<" "<<0<<endl;
continue;
}
ll p=abs(n-k);
cout<<p<<" "<<min({n%p, k%p, p-(... |
Problem: 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 divis... | #include <iostream>
#include <fstream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#define MAX_N 10002
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int main(){
int t; cin >> t;
while(t--){
ll a,b; cin >> a... |
Problem: 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 divis... | //created by Whiplash99
import java.io.*;
import java.util.*;
public class A
{
private static long diff(long A, long B){return (A>=B)?A-B:B-A;}
public static void main(String[] args) throws Exception
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int i,N;
... |
Problem: 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 divis... | #include <iostream>
using namespace std;
long long int gcd(long long int a, long long int b)
{
if (a == 0)
return b;
if (b == 0)
{
return a;
}
if (a == b)
return a;
if (a > b)
return gcd(a-b, b);
return gcd(a, b-a);
}
int main()
{
int t;
cin>>t... |
Problem: 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 divis... | import sys, os.path
if(os.path.exists('input.txt')):
sys.stdin = open("input.txt","r")
sys.stdout = open("output.txt","w")
############################################
def gcd(a,b):
if(a%b==0):
return b
return gcd(b, a%b)
for t in range(int(input())):
a , b = list(map(int,input().spl... |
Problem: 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 divis... | t=int(input())
for i in range (t):
a,b=map(int,input().strip().split())
if a==b:
print(0,0)
elif abs(a-b)==1:
print(1,0)
else:
gcd=abs(a-b)
minimum=min(a,b)
temp=minimum//gcd
prv=(minimum-(temp*gcd))
nxt=((temp+1)*gcd)-minimum
print(gcd,min... |
Problem: 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 divis... | #include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t--)
{ ll a,b,d;
cin>>a>>b;
if(a==b)
{
cout<<0<<" "<<0<<"\n";
}
else if... |
Problem: 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 divis... | #include <iostream>
using namespace std;
#include<bits/stdc++.h>
#define ll long long
ll closestMultiple(ll n, ll x)
{
if(x>n)
return x;
n = n + x/2;
n = n - (n%x);
return n;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
... |
Problem: 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 divis... | I=lambda: map(int, raw_input().split())
t = input()
for _ in xrange(t):
a, b = I()
d = abs(a-b)
if d==0:
print '0 0'
continue
q = min(a%d, (-a)%d)
print str(d)+' '+str(q) |
Problem: 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 divis... |
import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;
public class CF {
private static FS sc = new FS();
private static class FS {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(""... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define loopf(i,a,b) for(int i=a;i<b;i++)
#define loopb(i,a,b) for(int i=a;i>b;i--)
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ff first
#define ss second
#define vc vector
#define vii vector<int>
#define vl... |
Problem: 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 divis... | import sys
input=sys.stdin.readline
for _ in range(int(input())):
a,b=map(int,input().split())
if(a==b):
print(0,0)
else:
dif=abs(a-b)
mi=min(a,b)
rem=mi%dif
print(dif,min(rem,abs(dif-rem))) |
Problem: 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 divis... |
import java.io.*;
import java.util.*;
public class contest {
static long gcd(long a,long b){
if(a==0){
return b;
}
return gcd(b%a,a);
}
static final int p = 1000000007;
static class edge{
int u, v;
edge(int i,int x){
this.u = i;
... |
Problem: 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 divis... | #include <iostream>
using namespace std;
using ll = long long;
void solve() {
ll a, b;
cin >> a >> b;
if (a == b ) {
cout << "0 0\n";
return;
}
ll dif = abs(a-b);
ll up = a%dif;
if (up > dif - up)
{
cout << dif << " " << dif - up << endl;
} else {
c... |
Problem: 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 divis... | #include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define pll pair<ll,ll>
#define pii pair<int,int>
#define vll vector<ll>
#define vi vector<int>
#define sz(v) (ll)v.size()
#define all(v) v.begin(),v.end()
#define pq_max priority_queue<ll... |
Problem: 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 divis... | #include <bits/stdc++.h>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
void err(istream_iterator<s... |
Problem: 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 divis... | import java.io.*;
import java.util.*;
public class MainClass {
public static void main(String[] args) {
Reader in = new Reader(System.in);
int t = in.nextInt();
StringBuilder stringBuilder = new StringBuilder();
while (t-- > 0) {
long a = in.nextLong(), b = in.nextLong()... |
Problem: 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 divis... | #include<iostream>
using namespace std;
#define long long long
int main()
{
long tt;
cin>>tt;
while(tt--)
{
long a,b;
cin>>a>>b;
long h1,m1;
h1=abs(a-b);
if(h1==0)
{
cout<<0<<" "<<0<<endl;
}
else if(a==0 || b==0)
{
cout<<max(a,b)<<" "<<0<<endl;
}
else
{
m1=min(a%h1,h1-a%h1);
... |
Problem: 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 divis... | import sys
#Library Info(ACL for Python/Pypy) -> https://github.com/not522/ac-library-python
def input():
return sys.stdin.readline().rstrip()
from math import gcd
def main():
t = int(input())
for i in range(t):
a,b = map(int,input().split())
if a == b:
print(0,0)
el... |
Problem: 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 divis... | #include <bits/stdc++.h>
#define endl '\n' //pls remove while debugging
#define ll long long int
using namespace std;
void solve()
{
ll a, b;
cin>>a>>b;
if (a == b) {
cout<<0<<" "<<0<<endl;
return;
}
ll dif = abs(a-b);
cout<<abs(a - b)<<" "<<min(a%dif, dif- a%dif)<<endl;
}
int... |
Problem: 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 divis... | import java.util.*;
import java.io.*;
public class Div730 {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////... |
Problem: 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 divis... | t = int(input())
for _ in range(t):
a,b = [int(x) for x in input().split()]
if(a<b):
temp=a
a=b
b=temp
diff = a-b
if(diff==0):
print('0 0')
elif(diff==1):
print('1 0')
else:
low = a//diff
if(a - low*diff > 0.5*diff):
low=low+1
c = low*diff
d = (low-1)*diff
step... |
Problem: 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 divis... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastReader s = new ... |
Problem: 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 divis... | #include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define p... |
Problem: 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 divis... | import java.io.*;
import java.util.*;
import java.text.DecimalFormat;
public class A {
static long mod=(long)1e9+7;
static long mod1=998244353;
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new... |
Problem: 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 divis... | #pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << '(' << ... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t;
cin >> t;
while (t--){
ll a, b;
cin >> a >> b;
if(a == b)
cout << "0 0" << endl;
else{
ll mE = abs(a - b); ll mA;
ll x1 = (a/mE + 1) * mE - a;
... |
Problem: 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 divis... | #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(x) x.begin() , x.end()
#define ld long double
#define debug(x) cout << #x << " = " << x << "\n"
const long long inf = 1e18 + 5LL;
const int inf32 = INT_MAX;
const int mod = 998244353 ; //1e9 + 7LL;
const int N = (1e6 + ... |
Problem: 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 divis... | for i in[*open(0)][1:]:
a,b=map(int,i.split())
if a==b:
print(0,0)
else:
g=e=abs(a-b)
c=min(a,b)
while g<c:
g+=e
if g-c < abs(g-e-c):
d=g-c
else:
d=abs(g-e-c)
print(e,d) |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ll t;
cin>>t;
while(t--)
{
ll a,b;
cin>>a>>b;
if(a==b)
{
cout<<"0"<<" "<<"0"<<endl;
}
else{
ll g=abs(a-b);
cout<<g<<" ";
cout<<min(a%g,g-a%g... |
Problem: 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 divis... | from math import gcd
for _ in range(int(input())):
a,b=map(int,input().split())
if a==b:print(0,0)
elif abs(a-b)==1:print(1,0)
else:print(abs(a-b),min(a%abs(a-b),abs(a-b)-a%abs(a-b)))
|
Problem: 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 divis... |
/*
/$$$$$ /$$$$$$ /$$ /$$ /$$$$$$
|__ $$ /$$__ $$ |$$ |$$ /$$__ $$
| $$| $$ \ $$| $$|$$| $$ \ $$ ... |
Problem: 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 divis... | from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
for _ in range(int(input())):
a,b=map(int,input().split())
if a==b:
print(0,0)
else:
print(abs(a-b),min(a%abs(a-b),(max(a,b)-b%abs(b-a))+abs(b-a)-max(a,b))) |
Problem: 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 divis... | import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
# region fastio
BUFSIZE = 81... |
Problem: 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 divis... | def gcd(a,b):
if(b==0):
return a
return gcd(b,a%b)
for t in range(int(input())):
a,b = map(int,input().split())
maxi = abs(a-b)
gd = gcd(a,b)
if(a==b):
print(0,0)
else:
diff = abs(a-b)
a=min(a,b)
moves = min(a%diff,diff-a%diff)
print(maxi,moves... |
Problem: 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 divis... | for _ in range(int(input())):
a, b = map(int, input().split())
excitement = abs(a - b)
if excitement != 0:
moves = min(a % excitement, excitement - a % excitement)
else:
moves = 0
print(excitement, moves)
|
Problem: 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 divis... | import java.util.*;
import java.io.*;
public class CR730A {
public static void main(String[] args) {
FastIO io = new FastIO();
int t = io.nextInt();
while (t --> 0) {
long a, b, c, d;
a = io.nextLong();
b = io.nextLong();
if (a > b) {
c = a;
... |
Problem: 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 divis... | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void testcase () {
ll a, b;
cin >> a >> b;
if (a < b)
swap (a, b);
if (a == b) {
puts ("0 0");
return;
}
ll diff = a - b;
cout << diff << ' ' << min (a % diff, diff - (a % diff)) << "\n";
return;
}
int main () {
int t = 1;
c... |
Problem: 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 divis... | #include<bits/stdc++.h>
#define ll long long
#define int ll
#define pb push_back
#define INF 1e18
#define MOD 1000000007
#define mp make_pair
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i... |
Problem: 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 divis... | #include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define fo... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
int a, b;
cin >> a >> b;
if (a == b) {
cout << "0 0\n";
return;
}
if (a < b) swap(a, b);
if (!b) {
cout << a << ' ' << 0 << '\n';
return;
}
int d = a - b;
int x = b % d;
cout << d << ' ' << min(x, d - x) << '\n';
... |
Problem: 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 divis... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import static java.lang.System.*;
public class Main {
static boolean[] isNotPrime = new boolean[20_100];
static {
for (int i = 2; i <= Math.sqrt(isNotPrime.length); i++) {
if ... |
Problem: 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 divis... | import sys
input=sys.stdin.readline
for _ in range(int(input())):
# n=int(input())
a,b=map(int,input().split())
# s=input().strip()
# a=(list(map(int,input().split())))
if a==b:
print(0,0)
continue
if b<a:
a,b=b,a
print(b-a,min(b-a-b%(b-a),b%(b-a))) |
Problem: 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 divis... | import sys
lines = sys.stdin.read().strip().split('\n')
for line in lines[1:]:
a, b = map(int, line.strip().split())
if b<a: a, b = b, a
if a==b: print('0 0')
else:
dif = b-a
r = a % dif
move = r if r*2 < dif else dif-r
print(f'{dif} {move}')
|
Problem: 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 divis... | import java.io.*;
import java.util.*;
public class Main{
static void main() throws Exception{
long a=sc.nextLong(),b=sc.nextLong();
if(a==b) {
pw.println("0 0");
return;
}
long dif=Math.abs(a-b);
pw.print(dif+" ");
pw.println(Math.min(Math.min((dif-(a%dif))%dif, (dif-(b%dif))%dif), Math.min(a%dif, b... |
Problem: 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 divis... | def main():
alpha = 'abcdefghijklmnopqrstuvwxyz'
ALPHA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
inf = 1e17
mod = 10 ** 9 + 7
# Max = 10 ** 1
# primes = []
# prime = [True for i in range(Max + 1)]
# p = 2
# while (p * p <= Max + 1):
#
# # If prime[p] is not
# # changed, the... |
Problem: 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 divis... | // 1543A.cpp
// Created by Ashish Negi
/******** All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#... |
Problem: 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 divis... | import java.io.*;
import java.util.StringTokenizer;
public class TaskA {
public static void main(String[] args) {
InputReader in = new InputReader(System.in);
PrintWriter out = new PrintWriter(System.out);
Solver sol = new Solver();
int testCount = 1; testCount = in.nextInt();
... |
Problem: 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 divis... | import java.util.*;
import java.lang.*;
import java.util.*;
public class answer {
static Scanner s=new Scanner(System.in);
static long mod=1000000007;
// static boolean[] visited;
// static ArrayList<Integer>[] edges;
// static long[] ans;
// static long[] weights;
public static void main(String[] args) {
... |
Problem: 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 divis... | #include<bits/stdc++.h>
#define ll long long
#define all( x ) x.begin() , x.end()
using namespace std ;
void solve()
{
// If there is only one test case make t = 1
ll a , b ;
cin >> a >> b ;
ll req = abs( a - b ) ;
ll moves = 1e18 ;
if( req )
{
ll x = min( a , b ) % req ;
... |
Problem: 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 divis... | 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 "r" not in file.mode
self.write = self.buffer.write if self.writabl... |
Problem: 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 divis... | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
public class A {
... |
Problem: 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 divis... | import java.io.*;
import java.util.*;
public class A730A {
public static void main(String[] args) {
JS scan = new JS();
int t = scan.nextInt();
while(t-->0){
long a = scan.nextLong();
long b = scan.nextLong();
if(a==b){
System.out.println... |
Problem: 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 divis... | import java.util.*;
public class ExcitingBets {
static long gcd(long a,long b) {
if(a==0)
return b;
return gcd(b%a,b);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
long a=sc.nextLong();
long... |
Problem: 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 divis... | import java.io.*;
public class A {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
String input[];
StringBuilder sb = new StringBuilder("");
long a, ... |
Problem: 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 divis... | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
//input from input.txt
freopen("input.txt", "r", stdin);
//output on output.txt
freopen("output.txt", "w", stdout);
#endif
ll tc;
cin>>tc;
for(int i=0;i<tc;i++)
{
... |
Problem: 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 divis... | # import math
t=int(input())
for i in range(t):
a,b=map(int,input().split())
d=abs(a-b)
if a==b:
print("0 0")
else:
print(d,min(b%d,d-b%d)) |
Problem: 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 divis... | import math
def solve():
a,b = map(int,input().split())
if a>b:
a,b = b,a
x = abs(b-a)
if a==b:
print(0,0)
else:
if a==0:
print(x,0)
else:
print(x,min(a%x,x-a%x))
t = int(input())
for _ in range(t):
solve() |
Problem: 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 divis... | import math
for i in range(int(input())):
a,b = map(int,input().split())
d =abs(a-b)
f = min(a,b)
if d==0 or d==1:
e = 0
else:
g= math.ceil(f/d)
l = f//d
e =min((d*g)-f,f-(l*d))
print(d,e) |
Problem: 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 divis... | #include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr) ,cout.tie(nullptr);
const int mod = 1000000007;
using namespace std;
void solve(){
ll a,b;
cin>>a>>b;
if(a==b){
cout<<0<<" "<<0<<endl;
return ;
}
if(a>b)
swap(a,b);
... |
Problem: 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 divis... | import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.*;
public class practice {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define int long long
void solve(){
int a,b;
cin>>a>>b;
if(a==b){
cout<<0<<' '<<0<<'\n';
return;
}
if(b<a)swap(a,b);
set<int>facts;
int diff=b-a;
int ans=diff;
int moves=b/diff;
if(b%ans==0){
cout<<ans<<" "<<0<<'\n';
return;
}else{
c... |
Problem: 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 divis... | import java.util.*;
public class p1543A {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scn=new Scanner(System.in);
int t=scn.nextInt();
for(int i=0;i<t;i++) {
long a=scn.nextLong();
long b=scn.nextLong();
if(a==b) {
System.out.println(0+" "+0);
}
else ... |
Problem: 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 divis... | from math import gcd
t = int(input())
for i in range(0,t):
a, b = map(int, input().split())
maxim = max(a,b)
minim = min(a,b)
a = maxim
b = minim
if ((a-b) == 1) or ((b-a) == 1):
print("1 0")
elif a==b:
print("0 0")
else:
#gcd(a,b) == gcd(a-b, b)
x = ... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
const double pi = acos(-1);
#define pb push_back
#define LL unsigned long long
int static dp[1005][1005];
#define RADHE KRISHNA
const int MOD = 1e9 + 7;
const int N = 1e6 + 2;
// int lcs(string s , string t , i... |
Problem: 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 divis... | 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 "r" not in file.mode
self.write = self.buffer.write if self... |
Problem: 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 divis... | import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import static java.lang.Math.ceil;
import static java.lang.Math.floor;
import java.io.*;
import java.math.*;
import java.util.*;
public class apples {
/*---------------------------------------CODE STARTS HERE--------... |
Problem: 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 divis... | t = int(input())
for case in range(t):
a,b = map(int, input().split())
if a==b:
print(0,0)
continue
ex = abs(a-b)
moves = min(a%ex, ex - a%ex)
print(ex, moves) |
Problem: 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 divis... | import math
for _ in range(int(input())):
a,b = map(int,input().split())
flag = True
if a==b:
flag = 'Red'
else:
if a<b:
ans = b-a
x = a%ans
y = ans - a%ans
c = min(x,y)
else:
ans = a-b
x = b%ans
... |
Problem: 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 divis... | import java.util.*;
import java.io.*;
public class Main {
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
#define int int64_t
void solve(){
int a,b; cin >> a >> b;
if(a == b){
cout << "0 0\n";
return;
}
if(a > b) swap(a,b);
int ans = b - a;
if(ans == a) cout << ans << " " << 0 << '\n';
else{
cout << ans << " " << min(a%ans,ans-a%ans) << '\n';
}
}
signed main(){
... |
Problem: 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 divis... | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Practice {
public static long mod = (long) Math.pow(10, 9) + 7;
public static long mod2 = 998244353;
public static int tt = 1;
public static ArrayList<Integer> p... |
Problem: 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 divis... | #!/usr/bin/env python
#from __future__ import division, print_function
import math
import os
import sys
#from fractions import *
from sys import *
from decimal import *
from io import BytesIO, IOBase
from itertools import accumulate,combinations,permutations,combinations_with_replacement,product
from collections import... |
Problem: 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 divis... | //package Competitve1;
//package compete;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
//import java.security.acl.LastOwnerException;
import java.util.*;
import java.util.Arr... |
Problem: 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 divis... | #include<bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
while(t--){
long long a, b;
cin >> a >> b;
long long maxx, minn;
maxx = max(a, b);
minn = min(a, b);
cout << maxx - minn << " ";
if(a == b){
... |
Problem: 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 divis... | def il(): #Input list
return list(map(int,input().split()))
def ii(): #Input int
return int(input())
def imi(): #Input multiple int
return map(int,input().split())
from math import *
t=ii()
for _ in range(t):
a,b=imi()
if (a==b): print(0,0)
else:
k=abs(b-a)
a=min(a,b)
x=m... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.