코딩/백준 [ALGORITHM](65)
-
백준 [ALGORITHM] - 듣보잡 (1764)
n, m = map(int, input().split()) lst = [] temp = [] ans = dict() for i in range(n+m): lst.append(input()) for i in range(len(lst)): if lst[i] in ans: ans[lst[i]] += 1 else: ans[lst[i]] = 1 temp = sorted([key for key, value in ans.items() if value != 1]) print(len(temp)) print(*temp,sep='\n')
2024.04.03 -
백준 [ALGORITHM] - 파스칼의 삼각형 (16395)
def pascal(n): triangle = [] for i in range(n): row = [1] * (i + 1) for j in range(1, i): row[j] = triangle[i - 1][j - 1] + triangle[i - 1][j] triangle.append(row) return triangle x, y = map(int, input().split()) result = pascal(x) print(result[x-1][y-1])
2024.03.25 -
백준 [ALGORITHM] - 이름 궁합 (15312)
import string def dp(null_lst): while len(null_lst) > 2: for i in range(len(null_lst) - 1): null_lst[i] = int(null_lst[i]) + int(null_lst[i+1]) null_lst[i] = str(null_lst[i])[-1] null_lst.pop() return null_lst lst = list(string.ascii_uppercase) num = [3, 2, 1, 2, 3, 3, 2, 3, 3, 2, 2, 1, 2, 2, 1, 2, 2, 2, 1, 2, 1, 1, 1, 2, 2, 1] lst = dict(zip(lst,num)) first_input = list(input().upper()) second_..
2024.03.25 -
백준 [ALGORITHM] - 피보나치수 4 (10826)
def fibo(n): if n == 0: return 0 elif n == 1: return 0 else: lst = [-1] * n lst[0] = 0 lst[1] = 1 for i in range(2, n): lst[i] = lst[i-1] + lst[i-2] return lst[-1] n = int(input()) result = fibo(n+1) print(''.join(str(result)))
2024.03.20 -
백준 [ALGORITHM] - 돌게임, 돌게임2 (9655,9656)
n = int(input()) if n%2 == 0: print("CY") else: print("SK") n = int(input()) if n%2 == 1: print("SK") else: print("CY")
2024.03.20 -
백준 [ALGORITHM] - 짐 챙기는 숌 (1817)
N, M = map(int, input().split()) cnt = 1 sum = 0 if N == 0: print(0) else: number = input().split(' ') for i in range(len(number)): temp = int(''.join(number[i])) if sum + temp > M: sum = temp cnt += 1 else: sum += temp print(cnt)
2024.03.11