Implementation(115)
-
[백준 31822] 재수강 [Python]
문제국민대학교에서는 수강 신청, 성적 조회 등 과목의 구분이 필요할 때 ’과목 코드’를 사용한다. 과목 코드는 10자리로 이루어져 있으며, 7번째 자리는 영어 알파벳 대문자 또는 숫자, 8번째 자리는 하이픈(-), 나머지 자리는 숫자로 이루어져 있다.당신은 망한 학점을 복구하기 위해 재수강을 해야 하는데, 재수강을 하기 위해서는 재수강할 과목과 과목코드의 앞 5자리가 일치하는 과목을 수강해야 한다. 재수강할 과목의 과목 코드와 수강 신청 가능한 과목 목록이 주어지면, 재수강으로 인정되는 과목이 몇 개가 있는지 출력하라.입력첫 번째 줄에 재수강할 과목의 과목 코드가 주어진다.두 번째 줄에 수강 신청 가능한 과목의 개수 𝑁이 주어진다. (1≤𝑁≤16) 그다음 𝑁개의 줄에 걸쳐 수강 신청 가능한 과목의 ..
2024.07.06 -
[백준 05753] Pascal Library [Python]
문제Pascal University, one of the oldest in the country, needs to renovate its Library Building, because after all these centuries the building started to show the effects of supporting the weight of the enormous amount of books it houses.To help in the renovation, the Alumni Association of the University decided to organize a series of fund-raising dinners, for which all alumni were invited. Thes..
2024.07.05 -
[백준 05751] Head or Tail [Python]
문제John and Mary have been friends since nursery school. Since then, they have shared a playful routine: every time they meet, they play Head or Tail with a coin, and whoever wins has the privilege of deciding what they are going to play during the day. Mary always choose Head, and John always choose Tail.Nowadays they are in college, but continue being truly good friends. Whenever they meet, the..
2024.07.05 -
[백준 05666] Hot Dogs [Python]
문제In 2012 a new world record was set in the famous Nathan’s Hot Dog Eating Competition: the champion, Joey Chestnut, ate 68 hot dogs in ten minutes, an amazing increase from the 62 hot dogs eaten by the same Chestnut in 2011.Nathan’s Famous Corporation, in Brooklyn, NY, is responsible for the contest. They make delicious hot dogs, famous worldwide, but when it comes to math they are not so good...
2024.06.28 -
[백준 05613] 계산기 프로그램 [Python]
문제덧셈, 뺄셈, 곱셈, 나눗셈을 할 수 있는 계산기 프로그램을 만드시오.입력입력의 각 줄에는 숫자와 +, -, *, /, =중 하나가 교대로 주어진다. 첫 번째 줄은 수이다. 연산자의 우선 순위는 생각하지 않으며, 입력 순서대로 계산을 하고, =가 주어지면, 그때까지의 결과를 출력한다. 주어지는 수는 108 이하의 양의 정수이다. 계산 중 결과는 0 또는 음수가 될 수 있지만, -108 ~ 108 범위를 넘지는 않는다. 또, 나눗셈에서 소수점은 버린다. 따라서, 100/3*3 = 99이다.피제수가 음수일 때 나눗셈을 하는 경우는 입력으로 주어지지 않는다.출력첫째 줄에 계산 결과를 출력한다.풀이단순한 사칙연산 문제다. '='을 입력받을 때까지 수식은 계속된다.나누는 경우에만 소수점을 버린다는 점에 유의하..
2024.06.27 -
[백준 05612] 터널의 입구와 출구 [Python]
문제상근이는 남산1호터널의 입구와 출구에서 1분에 통과하는 차량의 수를 조사했다. 이때, 터널에 차량이 가장 많이 있었을 때, 몇 대 있었는지 구하는 프로그램을 작성하시오.입력첫째 줄에 조사한 시간 n이 주어진다. 둘째 줄에는 조사를 시작할 때, 터널 안에 들어있는 차량의 수 m이 주어진다. 다음 n개 줄의 i번째 줄(i = 1 ~ n)의 정보는 조사를 시작한지 (i-1)분이 경과한 시점부터 i분 경과할 때 까지 1분에 입구를 통과한 차의 수와 출구를 통과한 차의 수이다. n은 10000보다 작거나 같고, 1분에 통과하는 차량의 수는 100이하이다.출력조사 시작하고 j분이 지난 시점 (j = 0~n)에서 터널 안에 있는 차량의 수를 Sj라고 하자. 이때, Sj의 최댓값을 출력한다. 만약, 터널 안에 있는..
2024.06.27 -
[백준 05607] 問題 1[Python]
문제A と B の 2 人のプレーヤーが, 0 から 9 までの数字が書かれたカードを使ってゲームを行う. 最初に, 2 人は与えられた n 枚ずつのカードを, 裏向きにして横一列に並べる. その後, 2 人は各自の左から 1 枚ずつカードを表向きにしていき, 書かれた数字が大きい方のカードの持ち主が, その 2 枚のカードを取る. このとき, その 2 枚のカードに書かれた数字の合計が, カードを取ったプレーヤーの得点となるものとする. ただし, 開いた 2 枚のカードに同じ数字が書かれているときには, 引き分けとし, 各プレーヤーが自分のカードを 1 枚ずつ取るものとする.例えば, A,B の持ち札が, 以下の入力例 1 から 3 のように並べられている場合を考えよう. ただし, 入力ファイルは n + 1 行からなり, 1 行目には各プレーヤのカード枚数 n が書かれており, i..
2024.06.26 -
[백준 05365] Decoder [Python]
문제 All the Sith messages are sent using a complex coding scheme. You have cracked their code and must write a program to decode coded messages. Their code works as follows. Each word in the coded message represents one letter in the decoded message. Use the first letter of the first word and for each subsequent word use the nth letter where n is the length of the previous word. If the previous w..
2024.06.24 -
[백준 05343] Parity Bit [Python]
문제A parity bit, or check bit, is a bit that is added to the end of a sequence of bits for error detection. In telecommunications and computing all data is transformed into a sequence of zeros and ones. For this problem you may assume that all information is coded using 8 bits, with the first 7 bits used for data and the last bit used as the parity bit. The parity bit is set to one if the number ..
2024.06.23 -
[2024 KAKAO WINTER INTERNSHIP] 가장 많이 받은 선물 [Python]
풀이이번 달 까지의 선물을 주고받은 기록과 선물 지수를 토대로 다음달에 선물을 많이 받는 사람을 예측하는 문제다.문제에서 주어진 조건은 다음과 같다.1. 선물 기록이 있다면 더 많은 선물을 준 사람이 선물을 받는다.2. 선물 기록이 없거나 같다면, 선물 지수가 더 큰사람이 받는다.선물 지수는 이번 까지 자신이 친구들에게 준 선물 수에서 받은 선물 수를 뺀 값이다.즉, 받은것보다 준 횟수가 더 많다면 선물 지수는 높아진다.먼저 3개의 dict을 만들어 주자.각각 선물을 주고받은 기록( gift_history ), 선물 지수( gift_level ), 다음 달에 받을 선물 수( give )이다.gift_history의 경우 여러명으로부터 여러개의 선물을 받기 때문에 중첩 구조로 구성하자.참고로 문제에서 자기..
2024.06.21