Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

DIF_GCD 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 :: string remove suffix python 
Python :: subscriptable meaning in python 
Python :: python convert float to whole part of number 
Python :: split function python 
Python :: python loops 
Python :: pythagoras theorem formula 
Python :: NumPy roll Example 
Python :: python tkinter treeview column width auto 
Python :: dict comprehension python 
Python :: python check if false in dict 
Python :: how to step or only print every two element of list python 
Python :: plotly pdf report 
Python :: insert an element in list python 
Python :: python use variable name as string 
Python :: insert function in list 
Python :: repl.it secret 
Python :: drop the first 10 values of list python 
Python :: find and replace subword in word python regex 
Python :: how to use re.sub 
Python :: Write a Python program to remove a key from a dictionary. 
Python :: how to handle response from tkinter messagebox.askquestion() function in Python 
Python :: python date time 
Python :: from random input python 
Python :: random.randint(0,20) + pyrthon 
Python :: open multiple plots python 
Python :: variable globale python 
Python :: get date only from datetimefiel django 
Python :: python string lenght 
Python :: python pip 
Python :: how to print random in python 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =