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

'알고리즘 문제' 카테고리의 다른 글

[백준] 1463번 1로 만들기  (0) 2020.01.21
[백준] 1261번 (시간 초과)  (0) 2020.01.21
[백준] 2747번 피보나치 수  (0) 2020.01.20
[백준] 5622번 다이얼  (0) 2020.01.20
[백준] 1316번 그룹 단어 체커  (0) 2020.01.20

+ Recent posts