백준 파이썬 Today I Learn 2023.06.25
6/ 25 파이썬 공부
1. 백준 27332
2 つの整数 A, B が与えられる.
2022 年 11 月 A 日の B 週間後の日が 2022 年 11 月ならば 1 を,2022 年 11 月でないならば 0 を出力せよ.
ただし,2022 年 11 月は 2022 年 11 月 1 日から 2022 年 11 月 30 日までの 30 日間であり,x 週間後の日とは (7 × x) 日後の日のことを指す.入力は以下の形式で与えられる.
A
B
2022 年 11 月 A 日の B 週間後の日が 2022 年 11 月ならば 1 を,2022 年 11 月でないならば 0 を出力せよ.
- 1 ≦ A ≦ 30.
- 1 ≦ B ≦ 5.
- 入力される値はすべて整数である
>>>해석
2개의 정수 A, B가 주어진다.
2022년 11월 A일의 B주일 후가 2022년 11월이면 1을, 아니면 0을 출력하라.
이때, 2022년 11월은 2022년 11월 1일부터 2022년 11월 30일까지 30일을 의미하며,
x주일 후의 날짜는 7*x일 후를 의미한다. 입력은 다음과 같은 형태로 주어진다.
A
B
2022년 11월 A일의 B주일 후가 2022년 11월이면 1을, 2022년 11월이 아니면 0을 출력한다.
- 1 ≦ A ≦ 30.
- 1 ≦ B ≦ 5.
- 입력되는 모든 값은 정수이다.
>>>코드
a = int(input())
b = int(input())
if a + b*7 <= 30:
print(1)
else:
print(0)
2. 백준 6810 ISBN
The International Standard Book Number (ISBN) is a 13-digit code for identifying books. These numbers have a special property for detecting whether the number was written correctly.
The 1-3-sum of a 13-digit number is calculated by multiplying the digits alternately by 1’s and 3’s (see example) and then adding the results. For example, to compute the 1-3-sum of the number 9780921418948 we add
9 ∗ 1 + 7 ∗ 3 + 8 ∗ 1 + 0 ∗ 3 + 9 ∗ 1 + 2 ∗ 3 + 1 ∗ 1 + 4 ∗ 3 + 1 ∗ 1 + 8 ∗ 3 + 9 ∗ 1 + 4 ∗ 3 + 8 ∗ 1
to get 120.
The special property of an ISBN number is that its 1-3-sum is always a multiple of 10.
Write a program to compute the 1-3-sum of a 13-digit number. To reduce the amount of typing, you may assume that the first ten digits will always be 9780921418, like the example above. Your program should input the last three digits and then print its 1-3-sum. Use a format similar to the samples below.
>>>해석
국제 표준 도서 번호(ISBN)는 책을 식별하기 위한 13자리 번호입니다.
이 번호에는 번호가 제대로 쓰인 것인지 확인할 수 있는 특별한 성질이 숨겨져 있습니다.
13자리 숫자의 1-3 합은 각 자리를 번갈아 1과 3으로 곱한 후 (예시를 참고합시다.) 그 값들을 더해 구할 수 있습니다. 예를 들어, 9780921418948의 1-3 합은 아래와 같은 덧셈을 통해 120임을 알 수 있습니다.
9 ∗ 1 + 7 ∗ 3 + 8 ∗ 1 + 0 ∗ 3 + 9 ∗ 1 + 2 ∗ 3 + 1 ∗ 1 + 4 ∗ 3 + 1 ∗ 1 + 8 ∗ 3 + 9 ∗ 1 + 4 ∗ 3 + 8 ∗ 1
ISBN의 특별한 성질은 1-3 합이 언제나 10의 배수라는 것입니다.
13자리 수의 1-3 합을 계산하는 프로그램을 작성합시다.
타자 양을 줄이기 위해, 첫 열 개의 자리는 언제나 위의 예시와 같이 9780921418이라 가정합시다.
당신의 프로그램은 마지막 세 자리를 입력 받아 1-3 합을 출력해야 합니다.
아래의 예제와 같은 형식으로 출력합시다. (The 1-3-sum is 120)
>>>코드
a = int(input())
b = int(input())
c = int(input())
r = 91 + a*1 + b*3 + c*1
print('The 1-3-sum is %d' %(r))
3. 백준 18330 Petrol
The government of Neverland has recently announced a new petrol rationing plan with an unexpected price hike. According to the new plan, each person receives a quota of 60 liters per month in a fuel card. Each liter of petrol costs 1500 Oshloobs if it is within quota. Any extra fueling costs 3000 Oshloobs per liter.
After recovering from the shock, Mahya is trying to figure out how dark is the future. The current month is coming to an end, and Mahya has some quota left in her fuel card, remaining available for the next month. A quota of 60 liters will also be added to her fuel card just at the beginning of the next month. She also has a prediction of the amount of petrol that will be used in the next month. She now wants to know how much she should pay for petrol in the next month. However, she is too lazy to do that on her own. So, she needs your help to calculate the cost for her.
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 fuel card at the end of current month.
Print the amount of money (in Oshloobs) that Mahya will pay for petrol in the next month.
>>>해석
네버랜드 정부는 최근 예기치 못한 가격 급등에 따라 새로운 휘발유 배급 계획을 발표했습니다.
새 계획에 따르면, 각 국민은 연료 카드에 월 60L를 한도로 설정 받습니다.
한도 내에서 휘발유 1L는 1500 오쉬룹의 가치를 지닙니다.
그 이상의 연료는 1L마다 3000 오쉬룹의 가치를 지닙니다.
가격 파동에서 회복된 뒤, 마히야는 미래가 얼마나 암울한지 전망하려 합니다.
이번 달은 거의 끝나가고, 마히야는 연료 카드에 다음 달로 이월 가능한 남은 한도가 약간 있습니다.
60L 한도는 다음 달이 시작할 때 추가로 더해질 것입니다. 그녀는 다음 달에 얼마만큼 휘발유를 쓸지도 예측했습니다. 그녀는 다음 달에 휘발유 값으로 얼마를 내야 하는지 알고 싶어합니다. 하지만 그녀는 게을러 직접 계산하지 못합니다. 따라서 당신이 그녀를 도와 휘발유 값을 계산해야 합니다.
입력은 두 줄입니다. 첫 줄에는 다음 달 사용할 휘발유의 양을 나타내는 정수 n (0 <= n <= 200)이 주어집니다.
둘째 줄에는 이번 달 마히야의 연료 카드에 남아있는 한도를 나타내는 정수 k가 주어집니다.
마히야가 다음 달에 내야 하는 휘발유 값을 (오쉬룹 기준으로) 출력합니다.
>>>코드
a = int(input())
b = int(input())
if a <= 60 + b:
print(1500 * a)
else:
print(1500 * (60+b) + 3000 * (a-b-60))