題目來源:https://toi-reg.csie.ntnu.edu.tw/question/201910/B1-FreeParking.pdf
線上檢驗:https://zerojudge.tw/ShowProblem?problemid=e621
求範圍區間內,不能被指定數字整除的數字,
要注意的是開頭跟結尾兩個數字都不能算進來。
程式碼如下:
有問題歡迎留言或傳訊討論。
n = int(input())
while n > 0:
n -= 1
ans = ""
s,e,d = tuple([int(i) for i in input().split()])
for i in range(s+1 , e):
if i % d != 0:
ans += str(i) + " "
if ans != "":
print(ans)
else:
print("No free parking spaces.")
沒有留言:
張貼留言