1206A - Choose Two Numbers - CodeForces Solution


math sortings *800

Please click on ads to support us..

Python Code:



import bisect
import random

mod = 10 ** 9 + 7
eps = 10 ** -9

def _miillerTest(d, n):
    a = 2 + random.randint(1, n - 4)
    x = pow(a, d, n)
    if (x == 1 or x == n - 1):
        return True
    while (d != n - 1):
        x = (x * x) % n
        d *= 2;
 
        if (x == 1):
            return False
        if (x == n - 1):
            return True
    return False;

def _isprime(n):
    if (n < 2 or n == 4):
        return False
    if (n <= 3):
        return True
    d = n - 1;
    while (d % 2 == 0):
        d //= 2
    for i in range(5):
        if (_miillerTest(d, n) == False):
            return False
 
    return True

def _gcd(a, b):
    return a if b == 0 else _gcd(b, a % b)
  

def _lcm(a, b):
  return a * b / __gcd(a, b)

def _mex(a):
    mex = 0
    a.sort()
    for x in a:
        if x <= mex:
            mex += 1
        else:
            break
    return mex

def _dist(x1, y1, x2, y2):
  return (x1 - x2) ** 2 + (y1 - y2) ** 2

def _getprimes(n, m):
    primes = []
    if n <= 2:
        primes.append(2)
    if n % 2 == 0:
        n += 1
    for i in range(n, m + 1, 2):
        if _isprime(i):
            primes.append(i)
    return primes
  
def _primefactors(n):
    ret = []
    x = n
    i = 2
    if _isprime(n):
        ret.append(n)
        return ret
    while i * i <= x:
        while n % i == 0:      
            ret.append(i)
            n //= i
            if _isprime(n):
                break
        i += 1
    if n > 1:
        ret.append(n)
    return ret
  
def _pollardrho(n):
    if n % 2 == 0: return 2
    if _isprime(n): return n
    while True:
        c = random.randint(2, n -1)
        f = lambda x: x**2 + c 
        x = y = 2 
        d = 1 
        while d == 1:
            x = f(x) % n 
            y = f(f(y)) % n 
            d = _gcd((x - y) % n, n)
        
        if d != n and _isprime(d): return d

def _sumdigit(n):
  ret = 0
  while n > 0:
    ret += n % 10
    n //= 10
  return ret

def _modinverse(n, m):
    return (n % mod) * (pow(m, mod - 2, mod) % mod) % mod


def lip(type = int):
	return list(map(type, input().split()))
 
def mip(type = int):
	return map(type, input().split())
 
def tip(type = int):
	return type(input())

def solve(t):
	n = tip()
	a = lip()
	m = tip()
	b = lip()
	
	print(max(a), max(b))
	
t = 1
for i in range(t):
    solve(i + 1)


Comments

Submit
0 Comments
More Questions

580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football
MATCHES Playing with Matches
HRDSEQ Hard Sequence
DRCHEF Doctor Chef
559. Maximum Depth of N-ary Tree
821. Shortest Distance to a Character
1441. Build an Array With Stack Operations
1356. Sort Integers by The Number of 1 Bits
922. Sort Array By Parity II
344. Reverse String
1047. Remove All Adjacent Duplicates In String
977. Squares of a Sorted Array
852. Peak Index in a Mountain Array
461. Hamming Distance
1748. Sum of Unique Elements
897. Increasing Order Search Tree
905. Sort Array By Parity
1351. Count Negative Numbers in a Sorted Matrix
617. Merge Two Binary Trees
1450. Number of Students Doing Homework at a Given Time
700. Search in a Binary Search Tree
590. N-ary Tree Postorder Traversal
589. N-ary Tree Preorder Traversal
1299. Replace Elements with Greatest Element on Right Side
1768. Merge Strings Alternately
561. Array Partition I
1374. Generate a String With Characters That Have Odd Counts