전체 글
-
[BOJ] 2750번: 수 정렬하기Algorithm/Baekjoon Online Judge 2022. 3. 23. 23:15
https://www.acmicpc.net/problem/2750 2750번: 수 정렬하기 첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수 주어진다. 이 수는 절댓값이 1,000보다 작거나 같은 정수이다. 수는 중복되지 않는다. www.acmicpc.net Python3 if __name__ == '__main__': N = int(input()) numbers = [] for i in range(N): numbers.append(int(input())) numbers.sort() print(*numbers, sep="\n") 파이썬 내장함수 sort를 사용했다. 정렬 내장함수 알고리즘이 궁금해서 찾아봤는데 병합정렬과 삽입정렬을 섞은 알고리즘으로 시간복잡도는..
-
[BOJ] 1436번: 영화감독 숌Algorithm/Baekjoon Online Judge 2022. 3. 22. 22:46
https://www.acmicpc.net/problem/1436 1436번: 영화감독 숌 666은 종말을 나타내는 숫자라고 한다. 따라서, 많은 블록버스터 영화에서는 666이 들어간 제목을 많이 사용한다. 영화감독 숌은 세상의 종말 이라는 시리즈 영화의 감독이다. 조지 루카스는 스타 www.acmicpc.net Python3 if __name__ == '__main__': N = int(input()) six_n = 666 cnt = 0 while True: if '666' in str(six_n): cnt += 1 if cnt == N: print(six_n) break six_n += 1 제일 작은 수인 666부터 1씩 증가시키면서 종말의 수라면 카운트를 증가시킨다. 카운트가 일치 했을 경우의 1씩..
-
[BOJ] 1018번: 체스판 다시 칠하기Algorithm/Baekjoon Online Judge 2022. 3. 22. 22:24
https://www.acmicpc.net/problem/1018 1018번: 체스판 다시 칠하기 첫째 줄에 N과 M이 주어진다. N과 M은 8보다 크거나 같고, 50보다 작거나 같은 자연수이다. 둘째 줄부터 N개의 줄에는 보드의 각 행의 상태가 주어진다. B는 검은색이며, W는 흰색이다. www.acmicpc.net Python3 def coloring(color, str_h, str_w): cnt = 0 for h in range(str_h, str_h+8): for w in range(str_w, str_w+8): if h % 2 == 0: if w % 2 == 0: if color != board[h][w]: cnt += 1 else: if color == board[h][w]: cnt += 1 ..
-
[BOJ] 7568번 : 덩치Algorithm/Baekjoon Online Judge 2022. 3. 21. 22:54
https://www.acmicpc.net/problem/7568 7568번: 덩치 우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩 www.acmicpc.net Python3 if __name__ == '__main__': N = int(input()) persons = [] for _ in range(N): persons.append(tuple(map(int, input().split()))) sizes = [1] * N for i in range(N-1): for j in range(i+1, N): w1, h1 = persons[i] w2..
-
[BOJ] 2231번: 분해합Algorithm/Baekjoon Online Judge 2022. 3. 21. 22:21
https://www.acmicpc.net/problem/2231 2231번: 분해합 어떤 자연수 N이 있을 때, 그 자연수 N의 분해합은 N과 N을 이루는 각 자리수의 합을 의미한다. 어떤 자연수 M의 분해합이 N인 경우, M을 N의 생성자라 한다. 예를 들어, 245의 분해합은 256(=245+2+4+5)이 www.acmicpc.net Python3 if __name__ == '__main__': num = int(input()) has_num = False for i in range(1, num, 1): dst_sum = i dst_num = i while dst_num >= 10: dst_sum += dst_num % 10 dst_num //= 10 dst_sum += dst_num if dst_..