백준 단계별 문제풀기 3단계 반복문 -> 빠른 A + B
-> input()으로 입력을 받으면 입력 개수가 많아질수록 속도가 느려질 수 있다. -> 시간초과 문제
->이를 해결하기위해 sys.stdin.readline()함수 사용!
stdin
파이썬 sys 모듈 안에 있는 stidin함수
-> stdin 함수는 숫자 및 문자를 input 할 때 사용.
-> 문자열 자체를 변수에 저장하고 싶을때에는 sys.stdin.readline().rstrip()
-> 개행문자가 맨 끝에 들어와도 int 변환이나 split()을 그대로 할 수 있다!
readline
-> 한줄 씩 읽어라!
-> 개행문자를 만날때까지 읽는다! (\n, \r, \r\n)
-> 개행문자까지 포함해서 가지고 온다.
개행문자란? -> 줄바꿈을 의미하는 문자!
map 함수
map ( function , iterable , * iterables )
-> iterable의 모든 항목에 함수를 적용하여 결과를 산출.
출처:
https://www.acmicpc.net/problem/15552
15552번: 빠른 A+B
첫 줄에 테스트케이스의 개수 T가 주어진다. T는 최대 1,000,000이다. 다음 T줄에는 각각 두 정수 A와 B가 주어진다. A와 B는 1 이상, 1,000 이하이다.
www.acmicpc.net
https://docs.python.org/3/library/functions.html#map
Built-in Functions
The Python interpreter has a number of functions and types built into it that are always available. They are listed here in alphabetical order.,,,, Built-in Functions,,, A, abs(), aiter(), all(), a...
docs.python.org