https://www.acmicpc.net/problem/16861
16861번: Harshad Numbers
We’re all familiar with harshad numbers. For this problem, you will ... what’s that? You aren’t familiar with harshad numbers? They’re also known as Niven numbers – does that ring a bell?? Anything??? Well, it’s a simple enough concept. A harsh
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
def cal(n):
answer = 0
while n>0:
answer+=n%10
n//=10
return answer
def sol(n):
if n%cal(n) == 0:
return True
else:
return False
if __name__ == '__main__':
n = int(input())
while True:
if sol(n):
print(n)
break
else:
n+=1
|
cs |
반응형
'python-algorithm' 카테고리의 다른 글
백준 16316 Baby Bites (0) | 2023.01.04 |
---|---|
백준 6190 Another Cow Number Game (0) | 2023.01.03 |
백준 23343 JavaScript (0) | 2023.01.03 |
백준 24267 알고리즘 수업 - 알고리즘의 수행 시간 6 (0) | 2023.01.03 |
백준 11328 Strfry (0) | 2023.01.02 |
댓글