알고리즘 문제
[백준] 1475번 방 번호
feelcoding
2020. 1. 20. 15:41
728x90
백준에서 가장 많이 풀린 문제 TOP 100중 한 문제
1475번: 방 번호
첫째 줄에 다솜이의 방 번호 N이 주어진다. N은 1,000,000보다 작거나 같은 자연수 또는 0이다.
www.acmicpc.net
n = input()
count = {'0' : 0, '1' : 0, '2' : 0, '3' : 0, '4' : 0, '5' : 0, '6' : 0, '7' : 0, '8' : 0}
for i in n:
if i == '0':
count['0'] += 1
elif i == '1':
count['1'] += 1
elif i == '2':
count['2'] += 1
elif i == '3':
count['3'] += 1
elif i == '4':
count['4'] += 1
elif i == '5':
count['5'] += 1
elif i == '6' or i == '9':
count['6'] += 1
elif i == '7':
count['7'] += 1
elif i == '8':
count['8'] += 1
a, b = divmod(count['6'], 2)
if b == 1:
count['6'] = count['6'] // 2 + 1
else:
count['6'] = count['6'] // 2
max = 0
for i, j in count.items():
if j > max:
max = j
print(max)
728x90