Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Maximize Difference codechef solution

# 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 :: django upload multiple files 
Python :: use get method request html page python 
Python :: how to create copy of all objects in list python 
Python :: mean pandas 
Python :: cascade models in django 
Python :: string + string in python 
Python :: pypdf2 advanced tutorial 
Python :: python Sum of all the factors of a number 
Python :: program to demonstrate encapsulation in python 
Python :: how to define a functio in python 
Python :: ssl socket python 
Python :: python construct a string 
Python :: python any in string 
Python :: remove last digit from number python 
Python :: how to add hyperlink in jupyter notebook 
Python :: parse invoice python 
Python :: python edit item in list 
Python :: reverse range python 
Python :: reading files in python 
Python :: load list from file python 
Python :: boto3 rename file s3 
Python :: python comments 
Python :: can list hold different data types in python 
Python :: np logical not 
Python :: dockerize django 
Python :: python inline if 
Python :: how to check if all values in list are equal python 
Python :: python separate strings into characters 
Python :: how to compare list and int in python 
Python :: python qr scanner 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =