Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

maximize difference codechef

# MD Murad Hossain
# Gamil: muradhossainm01@gmail.com
# Accepted Ho ja:

try:
    for _ in range(int(input())):
        n,m = map(int,input().split())
        if m < 2*n:
            print(m,m)
        elif m >= 2*n and m%n == 0:
            print(m,n)
        else:
            res = 0
            res_2 = 0
            div = m//2
            if m >= 2*n:
                div = 2*n
            Min = 0
            for i in range(n,div):
                d = m//i
                c_Min = (i*d)-i
                if c_Min > Min:
                    res = i
                    res_2 = i*d
                    Min = c_Min
            print(res,res_2)
except:
    pass
Comment

PREVIOUS NEXT
Code Example
Python :: DIF_GCD 
Python :: how to append a tuple to a list 
Python :: stemmer nltk 
Python :: python child class call parent method 
Python :: python run things at certain datetimes 
Python :: clipboard python 
Python :: target encoder sklearn example 
Python :: Python script from c++ 
Python :: extract images from pdf 
Python :: python split range into n groups 
Python :: Generate bootstrap sample 
Python :: best way to access nested key in python 
Python :: pytest create server 
Python :: null in python 
Python :: apply 2d mask to 3d array python 
Python :: remove punctuation 
Python :: python write column csv 
Python :: python for in range 
Python :: chat application in python 
Python :: how to make an array python 
Python :: How to Replace substrings in python 
Python :: numpy maximum 
Python :: python using secrets 
Python :: guessing game python 
Python :: python tutorial 
Python :: dynamically create python dictionary 
Python :: jupyter notebook not opening 
Python :: Removing Elements from Python Dictionary Using clear() method 
Python :: swapping upper case and lower case string python 
Python :: qr scanner 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =