Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

DIVAB codechef 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))
Source by www.codechef.com #
 
PREVIOUS NEXT
Tagged: #DIVAB #codechef #solution
ADD COMMENT
Topic
Name
5+8 =