Home
Justnote
Cancel

[Python] 백준 2869번 : 달팽이는 올라가고 싶다

Problem https://www.acmicpc.net/problem/2869 Solution 오답 코드 (시간초과) a,b,v = map(int, input().split()) day = 1 snail_height = 0 while 1: snail_height+=a if v <= snail_height: bre...

[Python] 백준 1929번 : 소수 구하기

Problem https://www.acmicpc.net/problem/1929 Solution 오답 코드1 def is_sosu(n): for i in range(2,n): if n % i == 0: return 0 return 1 m, n = map(int, input().split()) for...

[Python] 백준 2292번 : 벌집

Problem https://www.acmicpc.net/problem/2292 Solution 오답 코드 # 해당 레이어의 벌집번호의 최댓값을 구하는 함수 def fibo(n): if n == 0: return 1 else: return fibo(n-1) + 6*n # 벌집이 속해있는 레이어를 구하는 ...

[Python] 백준 1361번 : 그룹 단어 체커

Problem https://www.acmicpc.net/problem/1316 Solution def is_group_word(word): counted = [] while word: if word[0] in counted: # 제일 앞 문자가 리스트에 있는지 확인 return 0 c...

[Python] 백준 2941번 : 크로아티아 알파벳

Problem https://www.acmicpc.net/problem/2941 Solution code1 from string import ascii_lowercase # 길이가 2인 알파벳 -> 1인 알파벳 순서로 저장 croatian_alpha = ['c=','c-','dz=','d-','lj','nj','s=','z='] + list(...

[Python] 백준 5622번 : 다이얼

Problem https://www.acmicpc.net/problem/5622 Solution code 1 def dial_time(letter): if 'A'<=letter<='C': return 3 elif 'D'<=letter<='F': return 4 elif 'G'&l...

[Python] 백준 2908번 : 상수

Problem https://www.acmicpc.net/problem/2908 Solution code1 첫번째 방법은 리스트를 활용한 방법이다. a, b = input().split() # 리스트로 변경 a_list = list(a) b_list = list(b) # 리스트 뒤집기 a_list.reverse() b_list.reverse() ...

TIL 220225

Python join 함수 '구분자'.join(리스트) 리스트를 구분자로 구분해 문자열로 합쳐서 반환하는 함수 예시) a = ['a','b','c'] b = '!'.join(a) print(b) 실행결과) a!b!c 응용) 리스트를 문자열로 변환 구분자를 비워둔 채로 사용하게 되면 리스트의 요소를 그대로 문자열로 바꿔준다. a = ['h','e'...

[Python] 백준 1157번 : 단어 공부

Problem https://www.acmicpc.net/problem/1157 Solution word_list = list(input().upper()) # list에서의 요소를 key로, value는 0으로 하는 dictionary 정의 word_count = {string : 0 for string in word_list} for i in...

[Python] 백준 1065번 : 한수

Problem https://www.acmicpc.net/problem/1065 Solution def is_hansu(number): if number >= 100: #100이상일 때만 체크 a = [] while(number != 0): # 각 자릿수 분리 a.append(numbe...