[파이썬][백준 1001번] A - B
1. 문제Permalink
[Bronze V] A-B - 1001Permalink
성능 요약Permalink
메모리: 30864 KB, 시간: 72 ms
분류Permalink
사칙연산(arithmetic), 구현(implementation), 수학(math)
문제 설명Permalink
두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오.
입력Permalink
첫째 줄에 A와 B가 주어진다. (0 < A, B < 10)
출력Permalink
첫째 줄에 A-B를 출력한다.
출처: 백준, https://https://www.acmicpc.net/
2. 해결방법 시간복잡도Permalink
- 단순 코딩
3. 문제 해결 및 코드Permalink
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a, b = map(int, input().split()) | |
print(a-b) |
-
주석을 참고하면서 이해를 돕습니다.Permalink
4. 알고리즘 및 해설Permalink
- 받아야 되는 값 a, b 를 map 함수를 통해 받는다. a, b = map()
- map 함수에는 받고자 하는 값의 형태 int, str, float …과 “ “를 기준으로 나눈 값을 받는다. a, b = map(int, input().split())
- 최종적으로 출력해준다. print(a - b)
5. 짚고 넘어가기Permalink
- 여기서 중요한 점은 input().split() 이 부분이다. 받은 값을 “ “를 기준으로 나눌 때 자주 사용되며, 앞으로 해결할 문제의 받는 값이 다수일 경우 자주 사용될 것이므로 기억하자!