### qwerty-1234's blog

By qwerty-1234, 8 days ago, ,

Problem : A.Minimum Integer

;li — l subscript(i); ri — r subscript(i); di — d subscript(i); xi — x subscript(i);

**I'm posting this after the contest had finished.I want to know the solution.**


You are given q queries in the following form: Given three integers li, ri and di, find minimum positive integer xi such that it is divisible by di and it does not belong to the segment [li,ri]. Can you answer all the queries? Recall that a number x belongs to segment [l,r] if l≤x≤r. Input: The first line contains one integer q(1≤q≤500) — the number of queries. Then q lines follow, each containing a query given in the format li ri di (1≤li≤ri≤109, 1≤di≤109). li, ri and di are integers. Output: For each query print one integer: the answer to this query.

n=int(input())
prob=list()

for i in range(n):
x=list(map(int,input().split()))
prob.append(x)

for i in range(n):
l,r,d=prob[i][0],prob[i][1],prob[i][2]
val=0
for j in range(0,l):
if (j%d)==0 and j!=0:
print("{}".format(j))
val=val+1
break
if val==0:
for k in range(r+1,1000000000):
if (k%d)==0:
print("{}".format(k))
break


•
• -16
•