백준

Algorithm/PS

[BOJ/백준] 4435 - 중간계 전쟁 [python]

문제 링크 4435번: 중간계 전쟁 첫째 줄에 전투의 개수 T가 주어진다. 각 전투는 두 줄로 이루어져 있다. 첫째 줄에 간달프 군대에 참여한 종족의 수가 주어진다. 이 값은 공백으로 구분되어 있으며, 호빗, 인간, 엘프, 드워프, www.acmicpc.net 문제 풀이 문제의 조건에 맞게 각 팀의 점수 합을 구해준 뒤, 출력해준다. 정답 코드 for i in range(1, int(input()) + 1) : G = list(map(int, input().split())) S = list(map(int, input().split())) G_score = G[0] + G[1] * 2 + (G[2] + G[3]) * 3 + G[4] * 4 + G[5] * 10 S_score = S[0] + (S[1] + ..

Algorithm/PS

[BOJ/백준] 4084 - Viva la Diferencia [python]

문제 링크 4084번: Viva la Diferencia 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있고, a, b, c, d가 순서대로 주어진다. 입력의 마지막 줄에는 0이 4개 주어진다. (1 ≤ a,b,c,d ≤ 2,000,000,000) www.acmicpc.net 문제 풀이 문제의 조건에 맞게 코드를 작성해주었다. 받은 리스트에 바로 값을 적용하는 경우, d - a 부분에서 값이 바뀐 a가 계산에 적용되기 때문에, 미리 a, b, c, d의 값을 따로 저장해주었다. 정답 코드 while True : lst = list(map(int, input().split())) if sum(lst) == 0 : break cnt = 0 while True : a,..

Algorithm/PS

[BOJ/백준] 3578 - Holes [python]

문제 링크 3578번: Holes You may have seen a mechanic typewriter — such devices were widespread just 15 years ago, before computers replaced them. It is a very simple thing. You strike a key on the typewriter keyboard, the corresponding type bar rises, and the metallic letter mo www.acmicpc.net 문제 풀이 이 문제는 주어진 입력값만큼의 구멍 갯수를 가지는 수를 출력하는 문제이다. 구멍을 하나도 가지지 않는 수의 경우, [1, 2, 3, 5, 7]의 숫자가 출력될 것이고, 구멍이 1개인 ..

Algorithm/PS

[BOJ/백준] 3533 - Explicit Formula [python]

문제 링크 3533번: Explicit Formula Consider 10 Boolean variables x1, x2, x3, x4, x5, x6, x7, x8, x9, and x10. Consider all pairs and triplets of distinct variables among these ten. (There are 45 pairs and 120 triplets.) Count the number of pairs and triplets that contain at least one variab www.acmicpc.net 문제 풀이 이 문제는 텍스트의 길이만 보고는 살짝 당황스러울 수 있는데, 결국에는 정확하게 반복문을 통해 풀어주면 쉽게 풀 수 있었다. (브론즈 3 문제라 더욱 간단한 방..

Algorithm/PS

[BOJ/백준] 3507 - Automated Telephone Exchange [python]

문제 링크 문제 풀이 간단한 사칙연산 문제이다. 00부터 99까지의 두 개의 수로 100부터 999까지의 수의 합을 나타낼 수 있는 방법의 수를 구하면 된다. 199 이상일 경우, 99 + 99를 초과하기 때문에 방법은 0가지이다. 198부터는 방법이 1씩 늘어나기 시작한다. 따라서 점화식은 200 - n - 1이다. 정답코드 n = int(input()) m = 200 - n - 1 if m < 0 : print(0) else : print(m)

Algorithm/PS

[BOJ/백준] 26546 - Reverse [python]

문제 링크 26546번: Reverse The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will be one line with a string and two integers i and j, separated by spaces. The first int, i, is the start index of the substring to be taken www.acmicpc.net 문제 풀이 문자열 중, 입력값으로 주어진 i와 j사이의 인덱스는 출력하지 않는 문제이다. 따라서, 문자열 인덱스 0부터 i까지, j부터 문자열의 끝까지 출력할 수 있도록 코드를 작성했다..

Algorithm/PS

[BOJ/백준] 26532 - Acres [python]

문제 링크 26532번: Acres You have a rectangular field you want to plant with corn. You know the dimensions of the field in yards, and you know that one bag of corn seed will cover 5 acres. Having passed all your elementary math courses you also know that 4840 square yards is equal www.acmicpc.net 문제 풀이 단순한 사칙연산 문제이다. 입력값이 야드 단위로 주어지고, 야드와 에이커의 너비는 4840 : 1이다. 5에이커 당 옥수수 종자 한 봉지를 쓸 수 있다고 하니, 9에이커일 경우,..

Algorithm/PS

[BOJ/백준] 26531 - Simple Sum [python]

문제 링크 26531번: Simple Sum You have hired someone to help you with inventory on the farm. Unfortunately, the new cowhand has very limited math skills, and they are having trouble summing two numbers. Write a program to determine if the cowhand is adding these numbers correctly. www.acmicpc.net 문제 풀이 간단한 문제이다. a, b의 합이 c와 같으면 "YES", 다르면 "NO"를 출력해준다. 정답 코드 a, _, b, _, c = input().split() if int(a) +..

chanwoong1
'백준' 태그의 글 목록 (14 Page)