Python

Algorithm/PS

[BOJ/백준] 5666 - Hot Dogs [python]

문제 링크 5666번: Hot Dogs 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, www.acmicpc.net 문제 풀이 입력값에 EOF가 들어올 때 까지 계속 계산 결과를 출력해준다. 계산은 단순 사칙연산이고, 소숫점 2번째 자리까지 출력한다. 정답 코드 try : while True : a, b =..

Algorithm/PS

[BOJ/백준] 5356 - Triangles [python]

문제 링크 5356번: Triangles Read in a letter and a number. The number indicates how big the letter triangle should be. The number indicating the size of the triangle will have a range from 0 to 250 (i.e., num>=0 and num

카테고리 없음

[BOJ/백준] 5354 - J박스 [python]

문제 링크 5354번: J박스 첫째 줄에 테스트 케이스의 개수가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있고, 박스의 크기가 주어진다. 박스의 크기는 10보다 작거나 같다. www.acmicpc.net 문제 풀이 이 문제는 단순 출력 문제이다. 단 고려해하는 경우가 있다. 케이스마다 빈 줄 하나씩 출력 박스의 크기가 1인 경우 개인적으로 박스를 만들어줄 때, 첫번째 줄과 마지막 줄을 따로 출력을 해줘서 박스의 크기가 1인 경우에 첫줄에서 "#"출력, 마지막줄에서 "#"출력이 되어 틀렸었다. 주의하자. 정답 코드 t = int(input()) for i in range(t) : n = int(input()) print("#" * n) mid = "#" + "J" * (n - 2) + "#" for..

Algorithm/PS

[BOJ/백준] 5342 - Billing [python]

문제 링크 5342번: Billing The accounting office is having troubling with billing each department for the supplies purchased last semester. Below is a chart of all the supplies and how much they cost. You must write a program that reads a list of the supplies and computes the total www.acmicpc.net 문제 풀이 각 물건에 해당하는 가격을 저장한 후, 입력값을 받을 때마다 물건의 가격을 더해준다. 출력은 소수점 2번째 자리까지만 출력해준다. 정답 코드 costs = {"Paper" : 5..

Algorithm/PS

[BOJ/백준] 5340 - Secret Location [python]

문제 링크 5340번: Secret Location Someone is waiting at a secret location and has sent a text message with the coordinates of their location. The message contains the latitude and longitude coordinates in degrees, minutes, and seconds. Of course, the message is encoded so you must write a www.acmicpc.net 문제 풀이 이 문제는 총 6줄의 문자열이 주어지는데, 각각의 문자열의 길이를 출력 조건에 맞게 출력해주면 된다. 단, 이 문제가 문자열 중 마지막 문자로 공백이 들어올 수도 ..

Algorithm/PS

[BOJ/백준] 5292 - Counting Swann’s Coins [python]

문제 링크 5292번: Counting Swann’s Coins Governor Weatherby Swann orders you to count the number of coins in the government treasury. To make the job more interesting you decide to say ”Dead” for all numbers that are a multiple of 3 and ”Man” for all numbers that are a multiple of 5. For www.acmicpc.net 문제 풀이 3의 배수이면 "Dead"를 출력하고, 5의 배수를 "Man"을 출력한다. 3의 배수이자 5의 배수라면 "DeadMan"을 출력한다. 그 외의 수일 경우, 출력하고 ..

Algorithm/PS

[프로그래머스] 두 큐 합 같게 만들기 [python]

문제 링크 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 문제 풀이 투포인터에 관한 문제이다. 합계를 미리 계산해두고, 조건에 따라 값을 추가하거나 빼는 형식으로 반복문을 돌려주었다. 이 문제의 제목에서부터 큐를 사용해야한다고 생각이 들겠지만, 사실 사용하지 않아도 된다. 오히려 파이썬에서는 deque를 사용하는 것이 리스트 사용보다 더 안좋을수도 있다. 이 문제를 풀기 위해서 일단, 기본적으로 확인해볼 것은 제한사항이다. 두 queue의 길이가 최장 300000까지 될 수 있다고 하니, 시간복잡도에 대해 조금 더 신경써주어야 한다. 그 외의 사항은 파이..

Algorithm/PS

[BOJ/백준] 5102 - Sarah's Toys [python]

문제 링크 5102번: Sarah's Toys Input will be a number of lines, with each line representing a night in Sarah’s house. Each line will have 2 whole numbers, separated by a space. The first number is how many stuffed toys she owns at the time. The second number is the number of toys left www.acmicpc.net 문제 풀이 몫과 나머지를 조건에 맞게 구해주는 문제이다. 두 입력값 a, b가 주어진다면, 현재 사라가 가지고 있는 장난감의 수는 a - b이다. 따라서 a - b의 값에 따라 출력..

chanwoong1
'Python' 태그의 글 목록 (12 Page)