Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

to divide or not to divide solution

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 :: stop word python 
Python :: print command python 
Python :: how to replace a string in py 
Python :: How to efficiently search for a pattern string within another bigger one, in Python? 
Python :: pandas describe 
Python :: Django Abstract base classe 
Python :: excel with python 
Python :: how to exit a function python 
Python :: how to append substring to string in specific position in python 
Python :: group by dataframe 
Python :: convert number to reversed array of digits python 
Python :: python timeit function return value 
Python :: what is serialization in django 
Python :: yahoo finance python documentation 
Python :: No installed app with label 
Python :: django add to database 
Python :: what is attribute in python 
Python :: minio python check if bucket exists 
Python :: How to filter words that contain atleast 2 vowels from a series 
Python :: Python Tuples Tuples allow duplicate values 
Python :: pkl save multiple files 
Python :: isprime lambda python 
Python :: find an element using id in requests-html library in python 
Python :: python map function 
Python :: conditional relationship sqlalchemy 
Python :: seaborn boxplot (both categorical and numeric data) 
Python :: unpacking in python 
Python :: CMake Error at pybind11/tools/FindPythonLibsNew.cmake:131 (message): Python config failure: 
Python :: create a thumbnail from video python 
Python :: UserWarning: Failed to initialize NumPy: numpy.core.multiarray failed to import (Triggered internally at 
ADD CONTENT
Topic
Content
Source link
Name
8+2 =