Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

to divide or not to divide

def solution(a,b,n):
    if a%b == 0:
        return -1
    c = n
    if c%a != 0:
        c = n+a-(c%a)
    while not(c%a == 0 and c%b !=0):
        c += a
    return c
for _ in range(int(input())):
    a,b,n = map(int,input().split())
    print(solution(a,b,n))
Comment

PREVIOUS NEXT
Code Example
Python :: python sqlite select column name 
Python :: change python from 3.8 to 3.7 
Python :: replace in lists python 
Python :: double a value in a list python 
Python :: how to create tkinter window 
Python :: python list object attributes 
Python :: how to speed up python code 
Python :: Difference between append() and extend() method in Python 
Python :: Python program to print positive numbers in a list 
Python :: pytest debug test 
Python :: what is queryset in django 
Python :: python - How to execute a program or call a system command? 
Python :: text color python tkinter 
Python :: zip lists 
Python :: python easter egg 
Python :: scikit learn library in python 
Python :: pandas to csv 
Python :: how to join basename and directory in python os 
Python :: plotly scatter facet change labels 
Python :: python remove header 
Python :: python if index not out of range 
Python :: limpar idle python 
Python :: Mac: Access your iCloud Documents folder with Jupyter Notebook or JupyterLab 
Python :: Example code of while loop in python 
Python :: pickle.load from gpu device to cpu 
Python :: python del var if exists 
Python :: python change version 
Python :: gitlab-ci.yml for python project 
Python :: flask production server 
Python :: recorrer lista desde el final python 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =