Algorithm

Algorithm/PS

[BOJ/백준] 9723 - Right Triangle [python]

문제 링크 9723번: Right Triangle For each test case, the output contains a line in the format Case #x: M, where x is the case number (starting from 1) and M is “YES” when the given triangle is a right triangle or “NO” otherwise. Note that the quotes are not required to be outputte www.acmicpc.net 문제 풀이 테스트마다 입력값들이 직각삽각형이 가능한 지 피타고라스 정리를 통해 판단한다. 정답 코드 for i in range(1, int(input()) + 1) : triangle = ..

Algorithm/PS

[BOJ/백준] 9713 - Sum of Odd Sequence [python]

문제 링크 9713번: Sum of Odd Sequence First line of the input contains T, the number of test cases. Each test case contains a single integer N. N is between 1 and 100. www.acmicpc.net 문제 풀이 주어진 케이스의 입력값마다 1부터 입력값까지의 홀수의 합을 구해 출력해준다. 정답 코드 for _ in range(int(input())) : n = int(input()) ans = 0 for i in range(1, n + 1, 2) : ans += i print(ans)

Algorithm/PS

[BOJ/백준] 9699 - RICE SACK [python]

문제 링크' 9699번: RICE SACK For each test case, the output contains a line in the format Case #x: followed by a sequence of integers, where x is the case number (starting from 1) and an integer that indicates the weight of a rice sack that will go to Al-Ameen. www.acmicpc.net 문제 풀이 각 케이스마다 최댓값을 출력한다. 정답 코드 for i in range(1, int(input()) + 1) : print("Case #{:d}: {:d}".format(i, max([*map(int, input(..

Algorithm/PS

[BOJ/백준] 9698 - SAHUR & IMSA’ [python]

문제 링크 9698번: SAHUR & IMSA’ Midhat is a Network Security Engineer, based in Sarajevo. He is assigned to do some important consultation projects around the globe in July and August 2013. It happened that Ramadhan (the fasting month for Muslim) falls during these months for the year 20 www.acmicpc.net 문제 풀이 시간, 분이 케이스마다 입력되는데, 입력된 시간에서 45분 전 시간을 출력해준다. 정답 코드 for i in range(1, int(input()) + 1) : H,..

Algorithm/PS

[BOJ/백준] 9635 - Balloons Colors [python]

문제 링크 9635번: Balloons Colors Your program will be tested on one or more test cases. The first line of the input will be a single integer T, the number of test cases (1 ≤ T ≤ 100). Followed by the test cases, the first line of each test case contains 3 integers separated by a singl www.acmicpc.net 문제 풀이 입력값마다 문제의 조건을 통해 출력해준다. 첫째 줄에 문제의 갯수 N, 컬러 X, Y가 주어진다. 두번 째 줄에서는 문제의 리스트가 주어진다. X, Y가 각각 문제의 리..

Algorithm/PS

[BOJ/백준] 9622 - Cabin Baggage [python]

문제 링크 9622번: Cabin Baggage The first line contains an integer t (1≤ t ≤ 300) which determines the number of test cases (i.e. cabin baggage to verify). The following t lines contain the measurement of cabin baggage. Each line contains 4 values which are length, width, depth and w www.acmicpc.net 문제 풀이 문제의 조건에 맞게 입력값을 처리해주면 된다. 정답 코드 cnt = 0 for _ in range(int(input())) : a, b, c, d = map(float, i..

Algorithm/PS

[BOJ/백준] 9550 - 아이들은 사탕을 좋아해 [python]

문제 링크 9550번: 아이들은 사탕을 좋아해 각 테스트 케이스마다 생일파티에 최대 몇 명의 아이들이 참석할 수 있는지 하나의 정수로 출력한다. www.acmicpc.net 문제 풀이 주어진 입력값을 조건에 따라 처리해주는 문제이다. 파이썬에서는 쉽게 몫을 구할 수 있고 리스트 컴프리헨션을 통해 간단하게 풀어줄 수 있다. 정답 코드 for _ in range(int(input())) : N, K = map(int, input().split()) candy = [*map(int, input().split())] print(sum([i // K for i in candy]))

Algorithm/PS

[BOJ/백준] 9517 - 아이 러브 크로아티아 [python]

문제 링크 9517번: 아이 러브 크로아티아 "I love Croatia"는 네델란드의 인기 티비 프로그램 "I love my country"의 포맷 라이센스를 수입해 만든 크로아티아의 티비쇼이다. 이 티비쇼에서 가장 인기있는 게임은 "Happy Birthday"이며, 이 게임에 대한 www.acmicpc.net 문제 풀이 주어진 입력값 중 시간을 계속 더해주면서 3분 30초 (210초) 이상이 되는 경우, 그 차례의 번호를 출력해준다. 정답 코드 K = int(input()) lst = [input() for _ in range(int(input()))] time = 0 for i in lst : T, Z = i.split() if Z == "T" : if time + int(T) < 210 : tim..