코딩/백준 [ALGORITHM](65)
-
백준 [ALGORITHM] - 주사위 (1233)
#include #include #include int main() { int a, b, c; int result; scanf("%d %d %d", &a, &b, &c); int *arr1 = (int *)malloc(a * sizeof(int)); int *arr2 = (int *)malloc(b * sizeof(int)); int *arr3 = (int *)malloc(c * sizeof(int)); int *value = (int *)malloc(a * b * c * sizeof(int)); for (int i = 0; i < a; i++) { arr1[i] = i + 1; } for (int j = 0; j < b; j++) { arr2[j] = j + 1; } for (int q = 0; q <..
2024.01.27 -
백준 [ALGORITHM] - 문서 검색 (1543)
string = list(input()) words = list(input()) count = 0 while True: string = ''.join(string) words = ''.join(words) str_len = len(string) string = string.replace(words,'') cmp_len = len(string) print((str_len - cmp_len) // len(words)) break
2024.01.25 -
백준 [ALGORITHM] - 숫자 카드 (10815)
card_book = {} number = int(input()) card = list(map(int, input().split(' '))) number_cmp = int(input()) card_cmp = list(map(int, input().split(' '))) for i in range(number_cmp): card_book[card_cmp[i]] = 0 for j in range(number): if card[j] in card_book: card_book[card[j]] = 1 else: pass print(' '.join(str(i) for i in card_book.values())) 이분탐색을 사용하지 않고, python의 dict 자료형을 활용한 해시맵 풀이
2024.01.24 -
백준 [ALGORITHM] - A와 B (12904)
S = list(input()) T = list(input()) while len(S) < len(T): if T[-1] == 'A': T.pop() elif T[-1] == 'B': T.pop() T.reverse() if ''.join(T) == ''.join(S): print(1) else: print(0) 그리디 알고리즘 구현 문제였는데 골드5 문제 치고 간단한 문제였음
2024.01.21 -
백준 [ALGORITHM] - 빈도 정렬 (2910)
N, C = map(int, input().split()) num = list(map(int, input().split())) print_list = list() hash_map = dict() for i in range(N): if str(num[i]) in hash_map.keys(): hash_map[str(num[i])][0] += 1 else: hash_map[str(num[i])] = [1, i] hash_map = sorted(hash_map.items(), key=lambda x: (x[1][0], -x[1][1]), reverse=True) for i in range(len(hash_map)): #print(hash_map[i][0]) #print(hash_map[i][1][1]) pri..
2024.01.20 -
백준[ALGORITHM] - 팩토리얼 0의 개수 (1676)
n = int(input()) lst = list(range(n,0,-1)) temp = '' count = 0 for i in range(len(lst)): temp = lst[-1] * lst[i-1] lst[-1] = temp temp = str(temp) count = 0 for digit in reversed(str(temp)): if digit == '0': count += 1 else: break print(count)
2023.10.31