baekjoon 15

[백준] 1339 단어 수학

N = int(input()) words = dict() for _ in range(N): word = input() len_word=len(word)# 가중치를 자리수로 두기 위한 값 for char in word:# ex) 'ABC' = 'A'=100, 'B'= 10 'C' =1 if not char in words: words[char] = 0 words[char] += 10**(len_word - 1) len_word -= 1 words=sorted(words.items(),key=lambda x: x[1], reverse=True)# 가중치를 값으로 정렬, 내림차순 result = 0 for i in range(len(words)):# 가중치가 가장 큰 값부터 차례대로 곱해서 더함 result ..

STUDY/Algorithm 2021.01.30

[백준] 1065 한수

# 첫째 줄에 1,000보다 작거나 같은 자연수 N이 주어진다. # 첫째 줄에 1보다 크거나 같고, N보다 작거나 같은 한수의 개수를 출력한다. def ishansu(str_number): # 한, 두자리 수인 경우 무조건 등차수열 if len(str_number)== 1 or len(str_number)==2: return True # 세자리 수인 경우 tmp = [] for ch in str_number: tmp.append(int(ch)) if (tmp[0]-tmp[1]) == (tmp[1]-tmp[2]):# 각 자리가 등차수열? return True else: return False N = int(input()) result = 0 for i in range(1, N+1): if ishansu(s..

STUDY/Algorithm 2021.01.30