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.*; import java.io.*; import java.math.*; /** * @author Naitik * */ public class Main { static FastReader sc=new FastReader(); static long dp[][]; static int mod=1000000007; static int max; static long bit[]; static long x; static long y; static long B[][]; public static void...
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
#Fast I/O import sys,os import math # To enable the file I/O i the below 2 lines are uncommented. # read from in.txt if uncommented if os.path.exists('in.txt'): sys.stdin=open('in.txt','r') # will print on Console if file I/O is not activated #if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w') # inputs 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
#include<bits/stdc++.h> using namespace std; typedef long long int ll; int main() { ll t; cin>>t; while(t--) { ll a,b; cin>>a>>b; if(a==b) cout<<0<<" "<<0<<endl; else { ll gcd = abs(b-a); ll minn = min(a%gcd,gcd-a%gcd); 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
from math import * t=int(input()) for i in range(t): temp=input().split() x=int(temp[0]);y=int(temp[1]) gre=abs(x-y) if(gre!=0): num = min(x%gre,y%gre,gre-x%gre,gre-x%gre) else: num = 0 print(str(gre)+" "+str(num))
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.lang.*; import java.util.*; public class rough { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n=sc.nextInt(); long[][] ans=new long[n][2]; for(int i=0;i<n;i++){ long a=sc.nextLong(); long b= 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.*; public class class24 { public static void main(String[] args) { Scanner input=new Scanner(System.in); int t=input.nextInt(); for(int i=0;i<t;i++) { long a=input.nextLong(); long b=input.nextLong(); long c=0,d=0,e=0; if(a==b) { System.out.println(...
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.*; import java.lang.*; import java.math.*; public class thisContestp1 { public static void main(String[] args) throws IOException { //BufferedReader br = new BufferedReader(new FileReader(new File("input.txt"))); BufferedReader br = new BufferedReader(new InputStreamReader(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
/* * akshaygupta26 */ import java.io.*; import java.util.*; public class A { public static void main(String[] args) { FastReader sc=new FastReader(); StringBuffer ans=new StringBuffer(); int test=sc.nextInt(); while(test-->0) { long a=sc.nextLong(); long b=sc.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
import os,sys,math from io import BytesIO, IOBase from collections import defaultdict,deque,OrderedDict import bisect as bi def yes():print('YES') def no():print('NO') def I():return (int(input())) def In():return(map(int,input().split())) def ln():return list(map(int,input().split())) def Sn():return input().strip() ...
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
'''input 4 8 5 1 2 4 4 3 9 ''' from sys import stdin,stdout for _ in range(int(stdin.readline())): a, b = map(int,stdin.readline().strip().split()) if a==b: stdout.write("0 0\n") else: diff = abs(a-b) lower = min(a,b)%diff upper = diff - lower stdout.write(str(diff)+" "+str(min(lower,upper))+"\n")
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> #define ll long long int #define st string #define pb(x) push_back(x) #define sz size() using namespace std; const ll maxn=1e3*2+1,maxv=1e6,mod=1e9; ll a1[maxn]; ll dp[maxn]; int main() { std::ios_base::sync_with_stdio(false);cin.tie(0),cout.tie(0); ll n,a,b; cin>>n; for(int i=1;i...
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> using namespace std; #define f(x,y,z) for(int x=y;x<z;++x) typedef long long ll; ll a, b, s, t; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); for(cin >> t; t--;) { cin >> a >> b; s = abs(a-b); cout << s << ' '; if(s < 2) c...
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 i in range(t): r, s = map(int, input().split()) if r == s: print(0, 0) else: a = min(r, s) b = max(r, s) q = b - a n = b % q print(q, min(n, q - n))
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 i in range(t): a,b=[int(x) for x in input().split()] g=abs(a-b) if g==0: print("0 0") else: lb=a//g hb=lb+1 if a-lb*g<hb*g-a: mo=a-lb*g else: mo=hb*g-a print(g,mo)
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(raw_input()) for _ in xrange(T): a, b = map(int, raw_input().split()) x = abs(a - b) if not x: print 0, 0 else: y = a % x y = min(y, x - y) print x, y
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
import java.util.*; import java.lang.*; import java.io.*; public class cf2 { static PrintWriter out; static int MOD = 1000000007; static FastReader scan; /*-------- I/O using short named function ---------*/ public static String ns() { return scan.next(); } public static int ni()...
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()) if a == b: g = 0 stps = 0 else: g = abs(a-b) stps = min(a%g,(g-a)%g) print(g,stps)
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.Scanner; public class A { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int test = scn.nextInt(); while (test-- > 0) { long a = scn.nextLong(); long b = scn.nextLong(); long diff = a - b; if (...
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.*; public class Main { 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 diff=(long)Math.abs(a-b); long max=(long)Math.max(a,b); if(di...
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 Ecitbets { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); for(int i=0;i<a;i++) { long b =sc.nextLong(); long c=sc.nextLong(); if(b==c) { System.out.println(0+" "+0); } else { long l=Math.max(...
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()) while t>0: a,b = map(int,input().split()) if a==b: print(0,0) else: x = abs(a-b) y = min(a%x,x-a%x) print(x,y) t=t-1
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.*; import java.lang.*; public class Main { static long mod = (long) Math.pow(10, 9) + 7; public static void main(String[] args) throws IOException { FastReader sc = new FastReader(); StringBuilder fout = new StringBuilder(); int t = sc.nextInt(); ...
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 gcd { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test_cases = sc.nextInt(); while(test_cases>0) { long a = sc.nextLong(); long b = sc.nextLong(); long diff = Math.abs(a-b); long i=diff==0?0:Math.min(a%diff,diff-a%diff);...
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 = map(int,input().split()) if(a == b): print('0 0') elif(abs(a-b) == 1): print('1 0') elif(a==0 and b!=0): print(str(b)+" 0") elif(b==0 and a!=0): print(str(a)+" 0") else: exc = abs(a-b) if(a < b): ...
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.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; long b; long dif; for(int i = 0; i < num; i++) { a = kb.nextLong(); b = kb.nextLong(); dif = Math.abs(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
#include <bits/stdc++.h> using namespace std; long long add(vector<long long> v,int n){ long long ans = 0; for(long long x: v){ ans+=x; ans = ans%n; } return ans; } void solve() { long long a,b; cin >> a >> b; if(b>a){ long long t = a; a = b; b = t; } cout << (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
#include <bits/stdc++.h> using namespace std; #define ll long long #define f(i,n) for(int i=0;i<n;i++) #define endl ("\n") #define pb push_back #define mp make_pair #define pl pair<ll, ll> #define vl vector<ll> #define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL); #define M 1000000007 const int N=2e5+2; ll ...
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()) if a == b: print(0, 0) continue if a > b: a, b = b,a c = b - a base1 = a // c base2 = base1 + 1 print(c, min(abs(base1 * c - a), abs(base2 * c - 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 math for _ in range(int(input())): a,b=map(int,input().split()) if a==b: print("0 0") else: ans1=abs(a-b) ans2=min(ans1-(a%ans1),a%ans1) print(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
#include <bits/stdc++.h> typedef long long int ll; const unsigned int MOD = 1000000007; using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif int t; cin >> t; for (int tt = 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
if __name__ == '__main__': t = int(input()); for _ in range(t): m, n = map(int,input().split()); if m == n: print('0 0'); else: M = abs(m - n); step = min(m,n); down_step = m%M; up_step = M - m%M; print(abs(m-n), 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
t=int(input()) for p in range(t): l=list(map(int,input().rstrip().split())) a=l[0] b=l[1] if a==b: print(f"0 0") # elif a==0 and b==0: # print(f"0 0") # elif a==0: # print(f"{b} 0") # elif b==0: # print(f"{a} 0") else: print(abs(a-b),end=' ') ...
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 codeforces { static FastReader fr; static StringBuilder res; static class FastReader { BufferedReader br; StringTokenizer st; BufferedWriter bw; 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 sys testing = len(sys.argv) == 4 and sys.argv[3] == "myTest" if testing: cmd = sys.stdout from time import time start_time = int(round(time() * 1000)) readAll = open(sys.argv[1], 'r').read sys.stdout = open(sys.argv[2], 'w') else: readAll = sys.stdin.read # ############ ---- I/O Functio...
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; void excbet() { long long a, b; cin >> a >> b; long long c = abs(a - b); long long d = 0; if( c != 0) d = a%c; cout << c << " " << min(d, c-d) << endl; } int main() { int t; cin >> t; for(int i=0; i<t; i++) { excbet...
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 solve(a, b): d = abs(a - b) if not d: print(0, 0) return print(d, min(a % d, d - (a % d))) t, = map(int, input().split()) for _ in range(t): a, b = map(int, input().split()) solve(a, b)
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 Codeforces { public static void main(String args[])throws Exception { BufferedReader bu=new BufferedReader(new InputStreamReader(System.in)); StringBuilder sb=new StringBuilder(); int t=Integer.parseInt(bu.readLine()); while(t--...
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 ll const MAX_N=1e7+5; int main(){ ll t; cin>>t; while(t--){ ll a, b; cin>>a>>b; ll ans=0; ll a1=max(a,b); ll a2=min(a,b); if(a1*2==b){ cout<<a1<<" "<<0<<endl; } else if(a1==a2){ cout<<0<<" "<<0<<endl; } el...
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<algorithm> #include<string> #include<cstring> #include<cstdio> #include<stdio.h> #include<cmath> #include<math.h> #include<vector> #include<set> #include<queue> #include<map> #include<sstream> #include<iomanip> #define forn(i,n) for(int (i)=0;i<(n);i++) #define pb push_back #define mp make_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
for data_samples in range(int(input())): arr = list(map(int, input().split())) if arr[0] == arr[1]: print("0 0") else: max_azart = abs(arr[0] - arr[1]) closest_nums = [min(arr) // max_azart * max_azart, (min(arr) // max_azart + 1) * max_azart] minimum_moves = min(abs(min(arr...
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 sys;import math;from collections import deque;from bisect import bisect_left,bisect_right;I=sys.stdin.readline;II=lambda :int(I());IN=lambda x:map(int,x.split());L=lambda x:list(IN(x));M=1000000007;P=print;T=True;F=False for _ in range(II()): a,b=IN(I()) if(a==b): print(0,0) continue if(b>a): a,b=b,a g...
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
for _ in range(int(input())): a,b=map(int,input().split()) s=abs(a-b) m=0 if s!=0: m=a%s print(s,min(m,s-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
#include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int i=a;i<n;i++) #define brep(i,a) for(int i=a;i>=0;i--) #define all(x) x.begin(),x.end() #define allara(x,n) x,x+n #define testcase(x) int x; cin>>x; while(x--) #define vec vector<int> #define vectorpair vector<pair<int,int>> #d...
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 range = xrange input = raw_input def gcd(a,b): while b: a,b = b,a%b return a t = int(input()) for _ in range(t): a,b = [int(x) for x in input().split()] goal = max(a,b) - min(a,b) print goal, (min(a%goal, -a%goal) if goal != 0 else 0)
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
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException { FastScanner f = new FastScanner(); int ttt=1; ttt=f.nextInt(); PrintWriter out=new PrintWriter(System.out); for(int tt=0;tt<ttt;tt++) { long a=f.nextLong(); long b=f.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
# Author : raj1307 - Raj Singh # Date : 07.07.2021 from __future__ import division, print_function import os,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 ii(): return int(input())...
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
for _ in range(int(input())): a,b=map(int,input().split()) temp=abs(a-b) if temp==0: print(0,0) continue temp2=min(a%temp,b%temp,abs(temp-(a%temp)),abs(temp-(b%temp))) print(temp,temp2)
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; #define int long long int t, a, b; signed main() { for(cin >> t; t--; ) { cin >> a >> b; if(a == b) { cout << "0 0\n"; continue; } if(a < b) swap(a, b); int ans = a - b; cout << ans << " " << min(ans-b%ans, b%ans) << "\n"; } }
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.StringTokenizer; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Scanner; im...
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.Arrays; import java.util.Random; import java.util.StringTokenizer; public class LinkedList { public static void main(String[] args) { FastReader scan = new FastReader(); PrintWriter out = new PrintWriter(System.out); Task solver = new Task(); 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
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; import java.util.concurrent.ThreadLocalRandom; //2 10, 3 11, 4 12, // 8 5, 24 15, 8 5 // 18 5 public class C { public static long gcd(long a, long b) { if (a == 0) return 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
import java.util.*; public class Exciting_Bets { public static void main(String[] args) { long a,b; Scanner sc=new Scanner(System.in); long input_count=sc.nextInt(); while(input_count-->0){ a=sc.nextLong(); 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
for i in range(int(input())): n,m=map(int,input().split()) x=abs(n-m) if x==0: print(0,0) else: y=n%x y=min(y,x-y) z=m%x z=min(z,x-z) print(x,min(y,z))
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 sbr{ public static void main(String args[]){ Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t-->0) { long a = s.nextLong(); long b = s.nextLong(); if (a ==b) System.out.println(0 + " " + 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
#include<iostream> #include<algorithm> #include<cmath> using namespace std; typedef long long LL; LL gcd(LL a,LL b){ return b ? gcd(b,b%a) : a; } void solve(){ LL x,y; cin>>x>>y; if(x<y)swap(x,y); if(x==y)cout<<"0 0"<<endl; else{ LL t = x - y; LL l = 0,r = 1e18 / t+1; whi...
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") else: diff = max(a,b)-min(a,b) print(diff,end = " ") print(min(a%diff,diff-a%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
import java.io.*; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.PriorityQueue; 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
import java.util.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int tc = scanner.nextInt(); for(int i=0;i<tc;i++) { long a = scanner.nextLong(); long b = scanner.nextLong(); if(a==b) { System.out.println("0 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.util.*; import java.lang.*; public class Contest { static void solve(long a,long b) { long temp; if(a>b) { temp = a; a = b; b = temp; } if(a==b) { System.out.println(0+" "+0); return; ...
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; void solve(){ long long a,b; cin>>a>>b; if(a==b) cout<<0<<" "<<0<<endl; else{ cout<< abs(a-b)<<" "<<min(a%abs(a-b), abs(a-b)-a%abs(a-b))<<endl; } } int main() { int t = 1; cin >> t; while (t--){ solve(); } ret...
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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * * @author Pranay2516 */ public class...
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; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import...
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 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) if(math.gcd(a,b)==r): print(r,0) else: e=a//r ...
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
# link: https://codeforces.com/contest/1543/problem/0 import os, sys, math 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 f...
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
for _ in range(int(input())): a, b = [int(__) for __ in input().split()] if a == b: print(0, 0) continue shit = abs(a - b) x = min(a, b) print(shit, min(x % shit, shit - (x % shit)))
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.math.BigInteger; import java.util.*; public class GCDEam { public static void main(String[] args) { handmadeInput.FastReader in = new handmadeInput.FastReader(); int t = in.nextInt(); 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
/* * Author:- Tanmay */ import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { FastScanner sc = new FastScanner(); PrintWriter out = new PrintWriter(System.out); // int t=1; int t=sc.nextInt(); // outer: while(t-- >0) { long a = sc.nextLong(), b = sc.nextLon...
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
# cf730div2 A ''' x + t = (y + t) * k = z x = y*k + t * (k-1) ''' T = int(input().strip()) for cas in range(T) : x,y = map(int,input().strip().split()) if (x==y) : print("0 0"); continue; if (x<y) : x,y = y,x; print("%d %d" %(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
#include <bits/stdc++.h> #define FOR(i, a, b) for (int i = (a); i < (b); ++i) #define RFOR(i, a, b) for (int i = (a); i > (b); --i) #define ALL(x) x.begin(), x.end() #define F first #define S second #define PB push_back #define MP make_pair using namespace std; using ll = long long; using ld = long double; typedef v...
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
// package com.company /* * @author :: Yuvraj Singh * CS UNDERGRAD AT IT GGV BILASPUR */ import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.lang.System.out; import static java.lang.Long.MAX_VALUE;...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; if (n == 1) { cout << 1; return 0; } cout << n * (n - 1) * 6 + 1; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; const int N = int(300000) + 5; long long int k, n, m, t, cnt, sum, ans, x, y; long long int a[N], b[N]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; if (n == 1) { cout << 1; return 0; } cnt = 1; while (n > 1) { sum += 12; ...
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int ans = 1, n; int main() { cin >> n; ans = (2 * n - 1) * (2 * n - 1) + 4 * (n - 1) * (n) / 2; cout << ans; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int res = 1; for (int i = 1, t = 12; i < n; i++, t += 12) res += t; cout << res << endl; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int main(int argc, char *argv[]) { int n; scanf("%d", &n); printf("%d\n", 6 * n * (n - 1) + 1); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int main() { int n, a[20000], i, s = 0; scanf("%d", &n); a[1] = 1; for (i = 2; i <= n; i++) { a[i] = 12 * (i - 1); s += a[i]; } printf("%d", s + 1); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
def star(n): a, b = 1, 12 for i in range(2, n + 1): a += b b += 12 return a print(star(int(input())))
PYTHON3
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class B { int INF = 1 << 28; void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long sum = 1; if( n == 1 ) { System.out.println(1); return...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int main() { long long int n, i, c = 0; scanf("%I64d", &n); printf("%I64d", 6 * n * (n - 1) + 1); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { int m, n, i, j, k, a, b; scanf("%d", &a); if (a == 1) printf("1\n"); else { printf("%d\n", (a - 1) * a / 2 * 12 + 1); } }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> const long long int INF = 1e15; using namespace std; const long long int MAX = 1e7 + 5; const long long int mod = 1e9 + 7; long long int gcd(long long int a, long long int b) { while (b > 0) { a = a % b; swap(a, b); } return a; } long long int binpow(long long int a, long long int...
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 1 + 6 * n * (n - 1); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int main() { int n, aux; scanf("%d", &n); aux = 1; for (int i = 2; i <= n; i++) aux += 12 * (i - 1); printf("%d", aux); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
n = int(input()) sum = (12 + 12*(n-1)) * (n - 2 + 1) / 2 print sum + 1
PYTHON
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; long star(int a) { if (a == 1) return 1; else return star(a - 1) + 12 * (a - 1); } int main() { int n; cin >> n; cout << star(n) << endl; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int main() { int n; scanf("%d", &n); printf("%d", 6 * n * (n - 1) + 1); return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> int dr[] = {-1, -1, -1, 0, 0, 1, 1, 1}; int dc[] = {-1, 0, 1, -1, 1, -1, 0, 1}; int dr_y[] = {-1, 0, 1, 0}; int dc_x[] = {0, 1, 0, -1}; int f[100000]; using namespace std; void init() { int i; f[1] = 1; for (int i = 2; i <= 18257; i++) f[i] = f[i - 1] + (i - 1) * 12; } int main() { int ...
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.text.*; public class Prac{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public InputReader(Inpu...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.io.*; import java.util.*; import java.math.*; public class Main { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); StringTokenizer tokenizer=null; public static void main(String[] args) throws IOException { new Main().execute(); } void debug(Object...os) { System.out...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.io.*; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.TreeMap; import java.util.TreeSet; public class Main{ public static void main(String[] args) throws Exception { int a = nextInt(); int ans = 1; for(int i = 1; i < a; i++){ a...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; cout << 6 * n * (n - 1) + 1 << endl; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.util.Scanner; public class ProblemB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); long sum = 1; for(int i = 1; i < a; i++){ sum += 12*i; } System.out.println(sum); } }
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long int n; cin >> n; cout << (n * (n - 1) * 6) + 1 << endl; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> #pragma GCC target("avx,avx2,fma") #pragma GCC optimization("O8") #pragma GCC optimization("unroll-loops") using namespace std; const long long int N = 1e6 + 20, mod = 1e9 + 7, inf = 2e18, dlt = 12250, maxm = 524288; int main() { long long n; cin >> n; cout << 1 + 6 * ...
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.util.Locale; import java.util.Scanner; public class StarSolver { private int n; public static void main(String[] args) { StarSolver solver = new StarSolver(); solver.readData(); int solution = solver.solve(); solver.print(solution); } private int gcd(int a...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main() { long long sl, sB, k; cin >> k; sl = k - 1; sB = k * 3 - 2; cout << ((sB + 1) * sB) / 2 + 3 * ((sl + 1) * sl) / 2; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import static java.lang.Double.parseDouble; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; ...
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
import java.util.Scanner; public class B_Star { public static void main(String[] args) { Scanner sc= new Scanner(System.in); int n=sc.nextInt(); int p=0; for (int i = 1; i <n; i++) { p=p+(12*i); } System.out.println(p+1); } }
JAVA
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; int main(int argc, const char *argv[]) { int n; cin >> n; cout << 12 * (n - 1) + 6 * (n - 1) * (n - 2) + 1; return 0; }
CPP
171_B. Star
<image> Input The input contains a single integer a (1 ≤ a ≤ 18257). Output Print a single integer output (1 ≤ output ≤ 2·109). Examples Input 2 Output 13
2
8
#include <bits/stdc++.h> using namespace std; long long gcd(long long x, long long y) { return (y == 0) ? x : gcd(y, x % y); } unsigned long long lcm(long long x, long long y) { return x / gcd(x, y) * y; } void the_end() {} int dy8[] = {0, 0, 1, -1, 1, -1, -1, 1}; int dx8[] = {1, -1, 0, 0, 1, -1, 1, -1}; int id8[] = {0...
CPP