6/ 17 파이썬 공부
1. 백준 25858 Divide the Cash
The UCF Programming Team coaches schedule practices regularly in fall and spring (by the way, all UCF students are welcome to the practices). During summer, the majority of the team members are gone but the coaches know how to make sure the students don’t get “rusty”. The coaches usually give prize money and reward the team members based on how many problems they solve during summer. For example, let’s assume the coaches have $1,000 in prize money and there are three students. Let’s also assume the three students solve, respectively, 5, 8 and 7 problems, i.e., a total of 20 problems. So, the reward for one problem will be $50 ($1000/20) and the three team members will receive, respectively, $250, $400 and $350.
Given the total prize money and the number of problems each team member has solved, compute the reward for each student.
The first input line contains two integers: n (1 ≤ n ≤ 30), indicating the number of team members and d (1 ≤ d ≤ 30,000), indicating the dollar amount to be divided among the students. Each of the next n input lines contains an integer (between 1 and 300, inclusive) indicating the number of problems a team member has solved. Assume that the input values are such that the reward for one problem will be an integer number of dollars.
Print the pay, in dollars, for each team member (in the same order as they appear in the input).
>>>해석
UCF 프로그래밍 팀의 코치들은 가을과 봄에 정기적으로 실습을 계획합니다
(모든 UCF 학생들은 실습을 환영합니다).
여름 동안 대부분의 팀원들은 떠나지만 코치들은 학생들이 "녹슬지" 않도록 하는 방법을 알고 있습니다.
코치들은 보통 여름 동안 얼마나 많은 문제를 해결했는지에 따라 팀원들에게 보상을 줍니다.
예를 들어 코치가 $1,000의 상금을 가지고 있고 학생이 3명이라고 가정해 보겠습니다.
또한 세 명의 학생이 각각 5, 8, 7개의 문제, 즉 총 20개의 문제를 풀었다고 가정해 봅시다.
따라서 한 문제에 대한 보상은 $50($1000/20)이며 세 명의 팀원은 각각 $250, $400 및 $350를 받게 됩니다.
총 상금과 각 팀원이 해결한 문제의 수를 고려하여 각 학생의 보상을 계산합니다.
첫째 줄에 팀원 수를 나타내는 n(1 <= n <= 30)과 학생들에게 나누어 줄 달러 금액을 나타내는 d(1 <= d <= 30,000)가 공백으로 구분되어 주어집니다. 다음 n개의 줄에 각각의 팀원이 해결한 문제의 수를 나타내는 1 이상 300 이하의 정수가 주어집니다. 한 문제에 대한 보상은 정수임이 보장됩니다.
각 팀원이 받을 수 있는 보상을 달러로 출력합니다. (입력에 주어진 것과 동일한 순서로).
>>>코드
n, d = map(int, input().split())
l = []
for i in range(n):
l.append(int(input()))
for i in range(n):
print(d * l[i] // sum(l))
2. 백준 26500 Absolutely
We will call the distance between any two values on the number line the absolute line distance. Given two values, find the absolute line distance and output it, rounded and formatted to one place of precision.
The first line contains a single positive integer, n, indicating the number of data sets. Each data set is on a separate line and contains two values on the number line, separated by a single space.
The absolute line distance between the two points, rounded to the nearest tenth, and print exactly one decimal digit.
>>>해석
수직선의 두 값 사이의 거리를 절대선 거리라고 합니다.
두 개의 값이 주어지면 거리의 절대값을 찾아 출력하고 소수점 첫째 자리로 반올림하고 형식을 지정합니다.
첫 번째 줄에는 데이터 세트의 수를 나타내는 단일 양의 정수 n이 포함됩니다.
각 데이터 세트는 별도의 줄에 있으며 단일 공백으로 구분된 줄에 두 개의 값을 포함합니다.
가장 가까운 소수점 첫쨰 자리로 반올림한 두 점 사이의 거리의 절대값이며 정확히 소수점 한 자리를 인쇄합니다.
>>>코드
for _ in range(int(input())):
a, b = map(float, input().split())
print('%.1f' %(abs(a-b)))
3. 백준 26531 Simple Sum
You have hired someone to help you with inventory on the farm. Unfortunately, the new cowhand has very limited math skills, and they are having trouble summing two numbers. Write a program to determine if the cowhand is adding these numbers correctly.
The first and only line of input contains a string of the form:
a + b = c
It is guaranteed that a, b, and c are single-digit integers. The input line will have exactly 9 characters, formatted exactly as shown, with a single space separating each number and arithmetic operator.
Print on a single line, YES if the sum is correct; otherwise, print NO.
>>>해석
농장 재고 관리를 도와줄 사람을 고용했습니다. 불행하게도 새로운 소작농은 수학 실력이 부족하여 두 숫자를 합하는 데 어려움을 겪고 있습니다. 소작농이 이 숫자를 올바르게 더하고 있는지 확인하는 프로그램을 작성하십시오.
첫 번째이자 유일한 입력 라인에는 다음 형식의 문자열이 포함됩니다.
a + b = c
a, b 및 c가 한 자리 정수임을 보장합니다. 입력 줄은 표시된 대로 정확하게 형식이 지정된 정확히 9개의 문자를 가지며 각 숫자와 산술 연산자를 구분하는 단일 공백이 있습니다.
한 줄에 인쇄하십시오. 합계가 정확하면 YES입니다. 그렇지 않으면 NO를 인쇄하십시오.
>>>코드
l = list(input().split())
if int(l[0]) + int(l[2]) == int(l[4]):
print('YES')
else:
print('NO')
'백준 > 백준 파이썬' 카테고리의 다른 글
백준 파이썬 Today I Learn 2023.06.19 (0) | 2023.06.26 |
---|---|
백준 파이썬 Today I Learn 2023.06.18 (0) | 2023.06.26 |
백준 파이썬 Today I Learn 2023.06.16 (0) | 2023.06.25 |
백준 파이썬 Today I Learn 2023.06.15 (0) | 2023.06.24 |
백준 파이썬 Today I Learn 2023.06.14 (0) | 2023.06.19 |