Python

Algorithm/PS

[BOJ/백준] 6903 - Trident [python]

문제 링크 6903번: Trident A trident is a fork with three tines (prongs). A simple picture of a trident can be made from asterisks and spaces: * * * * * * * * * ******* * * * * In this example, each tine is a vertical column of 3 asterisks. Each tine is separated by 2 spaces. The ha www.acmicpc.net 문제 풀이 삼지창을 출력하는 문제이다. "*"을 주어진 간격에 맞추어 찍어준다. 정답 링크 t = int(input()) s = int(input()) h = int(input()) fo..

Algorithm/PS

[BOJ/백준] 6889 - Smile with Similes [python]

문제 링크 6889번: Smile with Similes A simile is a combination of an adjective and noun that produces a phrase such as "Easy as pie" or "Cold as ice". Write a program to input $n$ adjectives $(1 \le n \le 5)$ and $m$ nouns $(1 \le m \le 5)$, and print out all possible similes. The first two l www.acmicpc.net 문제 풀이 이 문제는 입력값을 두 개의 리스트에 담아 각각의 조합을 출력해주는 문제이다. 정답 코드 n = int(input()) m = int(input()) lst..

Algorithm/PS

[BOJ/백준] 6845 - Federal Voting Age [python]

문제 링크 6845번: Federal Voting Age The input will consist of a number n (1 ≤ n ≤ 100) on a single line, indicating the number of birthdays to evaluate. Then, each of the following n lines, will be of the form y m d, where y is the year of a potential voter’s birth (0 ≤ y ≤ 2007), www.acmicpc.net 문제 풀이 2007년 2월 27일 선거에 선거할 수 있는 나이일 경우 Yes를 출력하고, 아닐 경우 No를 출력해준다. 예제 입력 예시를 보면, 1989년 2월 28일 생은 No이지만, ..

Algorithm/PS

[BOJ/백준] 6830 - It’s Cold Here! [python]

문제 링크 6830번: It’s Cold Here! Canada is cold in winter, but some parts are colder than others. Your task is very simple, you need to find the coldest city in Canada. So, when given a list of cities and their temperatures, you are to determine which city in the list has the lowest tempe www.acmicpc.net 문제 풀이 이 문제는 주어지는 입력값 중 가장 낮은 온도의 도시를 출력하는 문제이다. 입력값이 얼마나 들어올 지 모르므로 try - except 문을 사용해 EOF가 입력될..

Algorithm/PS

[BOJ/백준] 6812 - Good times [python]

문제 링크 6812번: Good times A mobile cell service provider in Ottawa broadcasts an automated time standard to its mobile users that reflects the local time at the user’s actual location in Canada. This ensures that text messages have a valid local time attached to them. For example www.acmicpc.net 문제 풀이 이 문제는 주어진 입력값으로 각각의 지역 시간대로 변환해 출력해야하는 문제이다. 이 문제에서 주의할 점은 다음과 같다. 입력값은 0부터 2359사이의 수이다. (ex. 0을 ..

Algorithm/PS

[BOJ/백준] 6794 - What is n, Daddy? [python]

문제 링크 6794번: What is n, Daddy? Natalie is learning to count on her fingers. When her Daddy tells her a number n (1 ≤ n ≤ 10), she asks “What is n, Daddy?”, by which she means “How many fingers should I hold up on each hand so that the total is n?” To make matters simple, her www.acmicpc.net 문제 풀이 1 부터 10까지의 수를 두 손으로 표현할 수 있는 방법의 수를 출력해주는 문제이다. 본인은 왼손이 항상 더 큰 수를 가지는 것으로 풀었다. 반복 규칙 (n 일 경우) 왼손이 항상..

Algorithm/PS

[BOJ/백준] 6784 - Multiple Choice [python]

문제 링크 6784번: Multiple Choice The input will contain the number N (0 < N < 10000) followed by 2N lines. The 2N lines are composed of N lines of student responses (with one of A,B,C,D or E on each line), followed by N lines of correct answers (with one of A,B,C,D or E on each line), in www.acmicpc.net 문제 풀이 처음 주어진 수만큼 리스트를 두 번 구성하는데, 두 리스트를 처음부터 순서대로 비교했을 때, 값이 같은 경우의 수를 구해준다. 최대 20000개의 문자가 들어올 수..

Algorithm/PS

[BOJ/백준] 6780 - Sumac Sequences [python]

문제 링크 6780번: Sumac Sequences In a sumac sequence, t1, t2, .., tm, each term is an integer greater than or equal 0. Also, each term, starting with the third, is the difference of the preceding two terms (that is, tn+2 = tn − tn+1 for n ≥ 1). The sequence terminates at tm if tm−1 www.acmicpc.net 문제 풀이 입력값으로 주어진 값이 t1, t2일 때, t3은 t2 - t1이고, t3 < t2의 관계여야 한다. 이 규칙을 지키는 수열의 길이를 구하면 된다. 정답 코드 cnt = 2 ..