BOJ_단계별로 풀어보기_2. 조건문 (파이썬, Python)

창고·2022년 11월 21일
0

https://www.acmicpc.net/step/4

1. 두 수 비교하기

a = list(map(int, input().split()))
if a[0] > a[1]:
    print(">")
elif a[0] < a[1]:
    print("<")
else:
    print("==")

2. 시험 성적

a = int(input())
if (90 <= a <= 100):
    print("A")
elif (80 <= a <= 89):
    print("B")
elif (70 <= a <= 79):
    print("C")
elif (60 <= a <= 69):
    print("D")
else:
    print("F")

3. 윤년

a = int(input())
if (a % 4 == 0):
    if (a % 100 == 0):
        if (a % 400 == 0):
            print(1)
        else:
            print(0)
    else:
        print(1)
else:
    print(0)

4. 사분면 고르기

x = int(input())
y = int(input())
if x>0:
    if y>0:
        print(1)
    else:
        print(4)
else:
    if y>0:
        print(2)
    else:
        print(3)

5. 알람 시계

time = list(map(int, input().split(' ')))
H = time[0]
M = time[1]
if M-45 >= 0:
    print(H, M-45)
else:
    if H-1 >= 0:
        print(H-1, 15+M)
    else:
        print(23, 15+M)

6. 오븐 시계

time = list(map(int, input().split(' ')))
add_time = int(input())
H = time[0]
M = time[1]
if M+add_time < 60:
    print (H, M+add_time)
elif M+add_time == 60:
    if (H+1 >= 24):
        print(H-23, 0)
else:
    if (M+add_time) % 60 == 0:
        cycle_hour = (M+add_time) // 60
        if H + cycle_hour >= 24:
            if (H + cycle_hour) % 24 == 0:
                print(0, 0)
            else:
                print((H + cycle_hour) % 24, 0)
        else:
            print(H + cycle_hour, 0)
    else:
        cycle_hour = (M+add_time) // 60
        if H + cycle_hour >= 24:
            print(H + cycle_hour-24, (M+add_time)%60)
        else:
            print(H + cycle_hour, (M+add_time)%60)

7. 주사위 세개

a = list(map(int, input().split(' ')))
if a[0] == a[1]:
    if a[1] == a[2]:
        print(10000 + 1000 * a[0])
    else:
        print(1000 + 100 * a[0])
elif a[1] == a[2]:
    print(1000 + 100 * a[1])
elif a[0] == a[2]:
    print(1000 + 100 * a[0])
else:
    print(max(a) * 100)
profile
공부했던 내용들을 모아둔 창고입니다.

0개의 댓글