본문 바로가기

전체 글735

[백준 05613] 계산기 프로그램 [Python] 문제덧셈, 뺄셈, 곱셈, 나눗셈을 할 수 있는 계산기 프로그램을 만드시오.입력입력의 각 줄에는 숫자와 +, -, *, /, =중 하나가 교대로 주어진다. 첫 번째 줄은 수이다. 연산자의 우선 순위는 생각하지 않으며, 입력 순서대로 계산을 하고, =가 주어지면, 그때까지의 결과를 출력한다. 주어지는 수는 108 이하의 양의 정수이다. 계산 중 결과는 0 또는 음수가 될 수 있지만, -108 ~ 108 범위를 넘지는 않는다. 또, 나눗셈에서 소수점은 버린다. 따라서, 100/3*3 = 99이다.피제수가 음수일 때 나눗셈을 하는 경우는 입력으로 주어지지 않는다.출력첫째 줄에 계산 결과를 출력한다.풀이단순한 사칙연산 문제다. '='을 입력받을 때까지 수식은 계속된다.나누는 경우에만 소수점을 버린다는 점에 유의하.. 2024. 6. 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. 6. 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. 6. 26.
[백준 05497] XOR 1 [TEXT] 문제You are implementing an application for a mobile phone, which has a black-and-white screen. The x-coordinates of the screen start from the left and the y-coordinates from the top, as shown in the figures. For the application, you need various images, which are not all of the same size. Instead of storing the images, you want to create the images using the phone’s graphics library. You may assu.. 2024. 6. 24.
[백준 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. 6. 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. 6. 23.