본문 바로가기
코딩테스트/백준 준비(과거)

(파이썬) 백준 1330, 2753, 14681, 2884

by junjunjun 2021. 6. 24.
반응형

1330 두 수 비교하기

a,b = map(int , input().split())
if a > b:
    print('>')
elif a < b:
    print('<')
else:
    print('==')

split()를 통한 input값을 공백단위로 분할

map을 통한 int로 형변환

 

2753 윤년

a = int(input())

if (a%4==0 and a%100!=0) or a%400==0: # (4의 배수 and 100의 배수 안됨) or 400의 배수
    print(1)
else:
    print(0)

 

14681 사분면 고르기

x = int(input())
y = int(input())

if x>0 and y>0:
    print(1)
elif x<0 and y>0:
    print(2)
elif x<0 and y<0:
    print(3)
elif x>0 and y<0:
    print(4)

 

 

2884 알람시계

h,m = map(int , input().split()) # 시간 분 입력 받음

if m-45 < 0:      # 분이 45분보다 작을 경우
    m = 60+m-45   
    if h == 0:    # 시간이 0인 경우 따로 처리
        h = 23   
    else:
        h = h-1 
else:
    m = m-45
print(h,m)

 

 

반응형

댓글