---
# System prepended metadata

title: k254. 拍七 (Seven)

---

# k254. 拍七 (Seven)
## 題目連結: [k254](https://zerojudge.tw/ShowProblem?problemid=k254)
## 解題想法
* 用for迴圈判斷是否為b的倍數或數字裡是否有b
* 變數count用來記錄拍手幾下

## 程式碼
```python=
#input
s,e,b,k = map(int,input().split())

#start
count = 0
isprint = False
for i in range(s,e+1):
    if str(b) in str(i) or i%b ==0:
        count += 1
        if count == k:
            print(i)
            isprint = True

#output
if isprint == False:
    print(-1)
