반응형
https://www.acmicpc.net/problem/10869
1. 문제
두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오.
2. 풀이
먼저 A, B에 들어올 문자들을 input()으로 받고 split()으로 나누어 변수에 저장한다
이후 int를 이용하여 A,B를 정수로 변환하고 각각의 사칙연산 기호에 대입해준다
3.코드
A, B = input().split()
print(int(A) + int(B))
print(int(A) - int(B))
print(int(A) * int(B))
print(int(A) // int(B))
print(int(A) % int(B))반응형
'백준 파이썬' 카테고리의 다른 글
| [백준] 18108번 : 1998년생인 내가 태국에서는 2541년생?! - [Python] (0) | 2025.11.06 |
|---|---|
| [백준] 10926번 : ??! - [Python] (0) | 2025.11.06 |
| [백준] 1008번 : A/B - [Python] (0) | 2025.11.06 |
| [백준] 10998번 : A×B - [Python] (0) | 2025.11.06 |
| 백준 파이썬[백준] 1001번 : A-B - [Python] (0) | 2025.11.06 |