Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

DIF_GCD

# 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 :: remove duplicates from list python keep order 
Python :: python for loop practice problems 
Python :: Merge two Querysets in Python Django while preserving Queryset methods 
Python :: The options auto_now, auto_now_add, and defa ult are mutually exclusive. Only one of these options may be present. 
Python :: python types of loops 
Python :: intialize 2d aray in python 
Python :: SciPy Spatial Data 
Python :: how to find a specific word in a list python 
Python :: collections.defaultdict(set) 
Python :: pandas rearrange rows based on datetime index 
Python :: how to put space in between list item in python 
Python :: tkinter convert Entry to string 
Python :: python find dir 
Python :: return foreignkey attribute django rest 
Python :: Split a list based on a condition 
Python :: syntax of calloc 
Python :: find type of an element in list python 
Python :: pandas sum group by 
Python :: remove watermark using python 
Python :: how to save plot in matplotlib 
Python :: Accessing elements from a Python Nested Dictionary 
Python :: Find Factors of a Number Using Function 
Python :: draw bipartite graph networkx 
Python :: adding new key in python 
Python :: matplot image axis 
Python :: django form custom validation 
Python :: python dictionary input 
Python :: python capitalize 
Python :: app.py 
Python :: qr code scanner using opencv 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =