본문 바로가기

백준1054

백준 30700 KOREA 문자열 만들기 https://www.acmicpc.net/problem/30700 30700번: KOREA 문자열 만들기 첫 번째 줄에 문자열 $S$가 주어진다. $S$는 영어 알파벳 대문자 K, O, R, E, A로만 이루어져 있으며, 문자열의 길이는 $10$ 이상 $1\,000$ 이하이다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 def solution(s): korea = ['K','O',"R",'E',"A"] current, answer = 0, 0 for i in s: if i == korea[current]: answer += 1 current = (current + 1) % 5 return answer if __name__ == '__main__': s .. 2023. 11. 27.
백준 28062 준석이의 사탕 사기 https://www.acmicpc.net/problem/28062 28062번: 준석이의 사탕 사기 준석이는 두 동생을 위해 사탕 가게에서 사탕을 최대한 많이 사 가려고 한다. 사탕 가게에는 $N$개의 사탕 묶음이 있으며 $i$번째 사탕 묶음에는 $a_i$개의 사탕이 있다. 준석이는 정말 부자라 사탕 www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 def solution(nums): answer = 0 odd_nums = [] for num in nums: if num % 2 == 0 : answer += num else: odd_nums.append(num) odd_nums.sort(reverse= True) answer += s.. 2023. 11. 27.
백준 26529 Bunnies https://www.acmicpc.net/problem/26529 26529번: Bunnies You’re going to raise farm animals and you decided to start with bunnies, the easiest of animals. To your surprise they are breeding like rabbits, so much so that you’re unable to count them accurately. However, you know that rabbits’ breeding patter www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def solution(n): answer = [1, 1] for i in ra.. 2023. 11. 25.
백준 15841 Virus Outbreak https://www.acmicpc.net/problem/15841 15841번: Virus Outbreak For each input value, the output contains a line in the format: Hour X: Y cow(s) affected, where X is the hour, and Y is the total affected cows that need to be euthanized based on the hour given by X. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 def solution(n): answer = [0, 1, 1] for i in range(3, n + 1): answer.append(answer[-1].. 2023. 11. 25.
백준 29738 Goodbye, Code Jam https://www.acmicpc.net/problem/29738 29738번: Goodbye, Code Jam Round 1은 Round 1A, Round 1B, Round 1C로 이루어진 $3$개의 라운드 중 $1$개의 라운드에서 상위 $1\,500$등 안에 들면 다음 라운드로 진출하는 방식이나 문제에서는 서술 편의상 $4\,500$등으로 표현했다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 def solution(n): if n 2023. 11. 23.
백준 30676 이 별은 무슨 색일까 https://www.acmicpc.net/problem/30676 30676번: 이 별은 무슨 색일까 별의 색을 출력한다. 빨간색이면 "Red", 주황색이면 "Orange", 노란색이면 "Yellow", 초록색이면 "Green", 파란색이면 "Blue", 남색이면 "Indigo", 보라색이면 "Violet"을 출력한다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 def solution(n): if 620 2023. 11. 23.
백준 30033 Rust Study https://www.acmicpc.net/problem/30033 30033번: Rust Study 첫 번째 줄에는 임스가 계획하고 공부한 일수 $N$이 주어진다. $(1 \le N \le 1\,000)$ 두 번째 줄에는 임스가 공부하고자 계획한 페이지 수 $A_1$, $A_2$, $\cdots$, $A_N$가 공백으로 구분되어 주어진다. $(1 \le www.acmicpc.net 1234567891011121314def solution(a, b): answer = 0 for an, bn in zip(a,b): if an 2023. 11. 16.
백준 29766 DKSH 찾기 https://www.acmicpc.net/problem/29766 29766번: DKSH 찾기 첫째 줄에 문자열이 입력된다. 문자열의 길이는 $1\,000$을 넘지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 def solution(s): return s.count('DKSH') if __name__ == '__main__': s = input() print(solution(s)) cs Python 문자열에는 count 메소드가 있어서 특정 문자열이 몇번 포함됐는지 셀 수 있습니다. 2023. 11. 16.
백준 30328 Java Warriors https://www.acmicpc.net/problem/30328 30328번: Java Warriors Jerry has earned acclaim as a renowned coach in the highly competitive realm of the International Collegiate Programming Contest (ICPC). His coaching prowess is exemplified by his unique approach — meticulously training his students to excel in ICPC comp www.acmicpc.net 1 2 3 4 5 6 7 8 def solution(n): return n * 4000 if __name__ == '__.. 2023. 11. 16.
백준 30664 Loteria Falha https://www.acmicpc.net/problem/30664 30664번: Loteria Falha Para cada caso de teste haverá uma linha na saída. Caso o número identificador do cartão seja um múltiplo de 42, imprima “PREMIADO”. Caso contrário, imprima “TENTE NOVAMENTE”. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 def solution(n): if n % 42 == 0: return 'PREMIADO' else: return 'TENTE NOVAMENTE' if __name__ == '__main__': while T.. 2023. 11. 16.
백준 2751 수 정렬하기 2 링크 : https://www.acmicpc.net/problem/2751 2751번: 수 정렬하기 2 첫째 줄에 수의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 절댓값이 1,000,000보다 작거나 같은 정수이다. 수는 중복되지 않는다. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 ㅔㅛimport sys if __name__ == '__main__': n = int(sys.stdin.readline()) ans = [0] * 2000001 for i in range(n): ans[int(sys.stdin.readline())+1000000] = 1 for i in range(2000001): if ans[i] !.. 2023. 9. 12.
백준 28444 HI-ARC=? 링크 : https://www.acmicpc.net/problem/28444 28444번: HI-ARC=? 첫째 줄에 각 문자에 들어갈 값 $H, I, A, R, C$ ($0 \leq H,I,A,R,C \leq 100$, $H,I,A,R,C$는 정수) 가 공백을 사이에 두고 순서대로 주어진다. www.acmicpc.net 1 2 3 4 5 6 7 8 def sol(nums): return nums[0] * nums[1] - nums[2] * nums[3] * nums[4] if __name__ == '__main__': nums = list(map(int, input().split())) print(sol(nums)) Colored by Color Scripter cs 사용된 알고리즘 : X 리스트로 입.. 2023. 9. 12.