728x90
반응형

count 함수를 사용하면 원하는 str에 원하는 문자가 몇 개 들어있는지 쉽게 확인할 수 있다.

ans = 0
n, d = map(int, input().split())
for i in range(1, n+1):
    ans += str(i).count(str(d))
print(ans)
728x90
반응형

+ Recent posts