분류 전체보기

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <1309-동물원>

import sysinput = sys.stdin.readlineN = int(input())if N == 1: print(3)else: # 공식 : 2*dp[n-1] + dp[n-2] dp = [0]*(N+1) dp[1] = 3 dp[2] = 7 for i in range(3, N+1): dp[i] = (2*dp[i-1] + dp[i-2])%9901 print(dp[N])https://www.acmicpc.net/problem/1309

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <4889-안정적인 문자열>

https://www.acmicpc.net/problem/4889 import sysinput = sys.stdin.readlinecnt = 0while True: s = input().strip() if '-' in s: break stack = list() cnt += 1 # 기존에 있는 안정적인 문자열 제거 for sc in s: if len(stack) == 0: stack.append(sc) else: if sc == '}' and stack[-1] == '{': stack.pop() else: stack.appen..

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <2792-보석 상자>

https://www.acmicpc.net/problem/2792 import sysinput = sys.stdin.readlineN, M = map(int, input().split(" "))li = list()for _ in range(M): li.append(int(input()))start = 1end = max(li)dap = 0while start N: start = mid+1 # 아니면 - else: end = mid-1 dap = midprint(dap)

코딩테스트/코딩테스트 문제풀이

[Python] 백준 <9375-해적왕 신해빈>

https://www.acmicpc.net/problem/9375 import sysinput = sys.stdin.readlineT = int(input())for _ in range(T): N = int(input()) dic = dict() for _ in range(N): a, b = map(str, input().split(" ")) # 종류별로 개수 저장 (안 입은 경우까지) dic[b] = dic.get(b, 1) + 1 dap = 1 # 모든 경우의 수 저장 for i, j in dic.items(): dap *= dic[i] # 모두 안입은 경우 -1 print(dap-1)

Yang Ji Woo
'분류 전체보기' 카테고리의 글 목록 (24 Page)