수학 205

[백준 20867] Rulltrappa [Python]

풀이 에스컬레이터의 걸어 올라가는 왼쪽과 가만히 올라가는 오른쪽 중 어디가 더 빠를지 계산하는 문제이다. 에스컬레이터에 사람이 없다면, 왼쪽 오른쪽 각각 (M / G), (M / S)의 시간이 걸릴것이다. 만약 사람이 L, R명이 있다면, 각 (1 / A), (1 / B)만큼의 대기시간이 추가된다. 소스코드 소스코드 보기 출처 20867번: Rulltrappa I exempel 1 är båda köer tomma, så Paulina kan omedelbart börja gå upp längs rulltrappan. Om hon står stilla i rulltrappan färdas hon med 1 trappsteg per sekund, så det tar $\frac{50}{1} = 50$ se..

[백준 20233] Bicycle [Python]

풀이 11월 한달 간, 21일을 자전거로 출근한다고 할 때 두개의 자전거 대여 서비스를 이용한다고 가정하고 월별 사용량을 계산해주면 된다. 기본 월 사용료(a, b)와 무료 이용시간 및 추가비용 발생조건을 고려해서 월 사용량을 계산해주면 된다. 소스코드 소스코드 보기 출처 20233번: Bicycle The first four lines of the input contain integers $a$, $x$, $b$, and $y$ ($0 \leq a, x, b, y \leq 100$), each on a separate line. The last line contains a single integer $T$ ($1 \leq T \leq 1440$) --- the total time spent on a b..

[백준 20215] Cutting Corners [Python]

풀이 w x h 크기의 작사각형을 자를 경우, 자르는 길이는 w + h 이다. 이때, 직사각형 모양으로 자르는 방법이 아닌, 직사각형에 대해 대각선으로 자를 때 길이와의 차이를 구하면 된다. 소스코드 소스코드 보기 출처 20215번: Cutting Corners A large coffee spill in the warehouse of the Busy Association of Papercutters on Caffeine has stained the corners of all paper in storage. In order to not waste money, it was decided that these dirty corners should be cut off of all pieces of paper. A..

[백준 19602] Dog Treats [Python]

풀이 서로 다른 종류의 간식의 개수가 주어진다. 입력되는 간식의 개수에 맞게 happiness score를 계산해주면 된다. 소스코드 소스코드 보기 출처 19602번: Dog Treats There are three lines of input. Each line contains a non-negative integer less than 10. The first line contains the number of small treats, S, the second line contains the number of medium treats, M, and the third line contains the number of large treats, www.acmicpc.net

[백준 18330] Petrol [Python]

풀이 매달 60리터의 연료를 리터당 1500원에 구매할 수 있다. 이번 달에 구매할 연료의 양과, 이월되어 싸게 구매할 수 있는 양이 주어진다. 구매할 양과 이월된 양 + 60리터의 대소를 비교해 쉽게 계산할 수 있다. 소스코드 소스코드 보기 출처 18330번: Petrol The input consists of two lines. The first line contains an integer n (0 ⩽ n ⩽ 200), specifying the amount of petrol that will be used in the next month. The second line contains an integer k (0 ⩽ k ⩽ 360), showing the quota left in Mahya’s fue..

[백준 17874] Piece of Cake! [Python]

풀이 정수 n, h, v 입력받고, 길이가 n인 정사각형 케이크에서 각각 가로/세로로 h와 v에서 케이크를 잘라 4등분 할 때, 가장 부피가 큰 케이크의 부피를 풀력해주면 된다. 참고로 케이크의 높이는 4 이다. 가로/세로가 최댓값인 경우를 계산해주자. 소스코드 소스코드 보기 출처 17874번: Piece of Cake! The input consists of a single line containing three integers n (2 ≤ n ≤ 10 000), the length of the sides of the square cake in centimeters, h (0 < h < n), the distance of the horizontal cut from the top edge of the c..

[백준 2407] 조합 [Python]

풀이 combination을 구현해 값을 출력하면 되는 문제이다. 다른 언어의 경우 bigInteger가 없으면 구현하기 까다롭지만, Python에서는 표준 라이브러리를 이용해 풀이할 수 있다. 문제에서 주어지는 최댓값인 100 C 50은 작은 편으로 빨리 풀고 넘기자. 날먹 츄르릅.. 소스코드 소스코드 보기 출처 2407번: 조합 n과 m이 주어진다. (5 ≤ n ≤ 100, 5 ≤ m ≤ 100, m ≤ n) www.acmicpc.net