반응형
백준 [단계별로 풀어보기]: (2단계) "조건문", python
1. 문제번호 및 정답비율

2. 문제별 필요 지식 및 풀이 포인트
더보기
# 1. 1330 두 수 비교하기
# 2. 9498 시험 성적
# 3. 2753 윤년
조건설정 잘 하기
# 4. 14681 사분면 고르기
# 5. 2884 알람 시계
# 6. 2525 오븐 시계
다시풀어보기
# 7. 주사위 세개
3. 문제별 풀이 코드
# 1. 1330 두 수 비교하기
A, B = map(int, input().split())
if A>B:
print('>')
elif A<B:
print('<')
else:
print('==')
# 2. 9498 시험 성적
score = int(input())
if 90 <= score <= 100: print("A")
elif 80 <= score < 90: print("B")
elif 70 <= score < 80: print("C")
elif 60 <= score < 70: print("D")
elif 0 <= score < 60: print("F")
# 3. 2753 윤년
y_leap = int(input())
if y_leap % 4 == 0 and y_leap % 100 != 0 or y_leap % 400 == 0: print("1")
else: print("0")
# 4. 14681 사분면 고르기
x = int(input())
y = int(input())
if x > 0:
print('1') if y > 0 else print('4') # A(결과) if 조건 else B : 조건문에 ':' 안씀
elif x < 0:
print('2') if y > 0 else print('3')
# 5. 2884 알람 시계
h, m = map(int, input().split())
if h != 0 and 45 <= m: print(h, m-45)
elif h != 0 and m < 45: print(h-1, m+15)
elif h == 0 and 45 <= m: print(h, m-45)
elif h == 0 and m < 45: print(h+23, m+15)
# 6. 2525 오븐 시계
'''다시 풀어보기'''
a, b = map(int, input().split())
c = int(input())
if b+c >= 60:
a = a + (b+c)//60
b = (b+c)%60
else:
b = b+c
if 24<=a:
a = a-24
print(a, b)
# 7. 주사위 세개
a,b,c = map(int, input().split())
m = 0
if a == b == c:
m = 10000 + a*1000
elif a == b or b == c:
m = 1000 + b*100
elif a == c:
m = 1000 + c*100
else:
if a>b and a>c: m = a*100
elif b>c and b>a: m = b*100
else: m = c*100
print(m)
반응형
'PS > BOJ : 단계별로 풀어보기' 카테고리의 다른 글
| 백준 [단계별로 풀어보기]: (6단계) "심화 1", python (2) | 2024.08.22 |
|---|---|
| 백준 [단계별로 풀어보기]: (5단계) "문자열", python (0) | 2024.08.20 |
| 백준 [단계별로 풀어보기]: (4단계) "1차원 배열", python (3) | 2024.08.17 |
| 백준 [단계별로 풀어보기]: (3단계) "반복문", python (2) | 2024.08.17 |
| 백준 [단계별로 풀어보기]: (1단계) "입출력과 사칙연산", python (1) | 2024.08.01 |