본문 바로가기
python-algorithm

[백준] 17618

by 무적김두칠 2021. 1. 5.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import sys
def singi(n):
    tmp=n
    cnt=0
    while tmp!=0:
        cnt+=tmp%10
        tmp=tmp//10
    if n%cnt==0 : return 1
    else : return 0
n=int(sys.stdin.readline())
ans=0
for i in range(1,n+1):
    if singi(i)==1: ans+=1
print (ans)
cs

일단 이 문제도 저처럼 하시면 python3 로는 시간초과뜹니다.
구현 방식이 얼추 비슷한것같은데 고민이 좀 더 필요해보이네요

반응형

'python-algorithm' 카테고리의 다른 글

[백준] 18247  (0) 2021.01.05
[백준] 17945  (0) 2021.01.05
[백준] 17450  (0) 2021.01.05
[백준] 17356  (0) 2021.01.05
[백준] 17284  (0) 2021.01.05

댓글