[백준/파이썬] 18398번 풀이
업데이트:
문제 정보
- 문제 출처: 백준 온라인 저지
- 문제 링크: 18398번 문제
- 문제풀이 코드 GitHub 링크
- 제출 언어: Python 3
풀이
문제
In one of the beautiful cities of Afghanistan two sisters are going to program a simple game to help them solve their mathematics homework. Their homework asks them to calculate the sum and multiplication of two numbers. Your task is to help them to build a simple program for their homework.
입력 요약
First line contains the number of test cases (T).
T test cases follow. For each test case, the first line represents the number of problems. Next N lines contains two integer numbers Ai, Bi.
출력 요약
For every input expecting two integer numbers, first one represents the addition of two given numbers and second represents the multiplication separated by space.
코드
for T in range(int(input())):
for _ in range(int(input())):
a,b=map(int,input().split())
print(a+b, a*b)
설명
핵심은 구현 관점에서 In one of the beautiful cities of Afghanistan two sisters are going to program a simple game to help them solve their mathematics homework. …를 만족하도록 로직을 구성하는 것입니다.
코드는 입력을 파싱한 뒤 조건 분기와 계산을 순서대로 수행하고, 문제에서 요구한 형식으로 결과를 출력합니다.
경계값과 예외 케이스도 함께 고려해 오답이 나기 쉬운 상황을 방지합니다.
댓글남기기