ky_u님의 블로그
BAEKJOON) 10953번, 11021번, 11022번, 2163번, 10699번, 2525번 본문
# 10953번
정답 코드 :
더보기
# A+B 6
t = int(input())
for i in range(0,t):
a, b = map(int, input().split(","))
c = a + b
print(c)
#11021 번
정답 코드 :
더보기
# A+B 7
t = int(input())
for i in range(1,t+1):
a, b = map(int, input().split())
c = a + b
print("Case #{}: {}".format(i,c))
f-string을 사용하여 print하는 방법도 존재하다. = print(f"Case #{i}: {c}")
#11022번
정답 코드 :
더보기
# A+B 8
t = int(input())
for i in range(1,t+1):
a, b = map(int, input().split())
c = a + b
print(f"Case #{i}: {a} + {b} = {c}")
# 2163번
정답 코드 :
더보기
a ,b = map(int,input().split())
c = a*b-1
print(c)
# 10699
# %Y는 2024를 출력하고 %y는 24만 출력한다.
정답 코드 :
더보기
from datetime import datetime
now = datetime.now()
a=now.strftime("%Y-%m-%d")
print(a)
# 2525번
# 여기서는 2가지 조건이 필요하다.
1. 24를 초과하면 0시가 된다.
2. 60분을 초과하면 1시간을 추가 해야한다는 것이다.
따라서 처음에 입력 받는 분과 다음에 추가로 입력되는 분을 더 한 total_m 변수를 생성해줬고, 그 값을 바탕으로 60으로 나눠 추가 시간을 만들어 기존 h와 합치고, 24을 초과하지 않게 %(나머지 연산자)를 통해 new_h변수 값을 저장했다. 그 다음 똑같이 total_m과 60을 %(나머지 연산자)을 하여 new_m변수를 만들어주어 해결했다ㅣ.
정답 코드 :
더보기
h,m=map(int,input().split())
add_m=(int(input()))
# 추가된 분을 저장하는 total_m 생성
total_m = m + add_m
new_h = (h+(total_m // 60)) % 24
new_m = total_m % 60
print(new_h,new_m)
'BAEKJOON' 카테고리의 다른 글
BAEKJOON) 코드 작성 2558번, 3046번, 10950번, 10951번, 10952번 (0) | 2024.11.18 |
---|