C-log

💡15552번 본문

🧠Algorithm/Baekjoon💡

💡15552번

4:Bee 2023. 12. 17. 12:32
728x90
import sys
T = int(input())

for i in range(T):
    A, B = map(int, sys.stdin.readline().split())
    print(A+B)

input을 사용하지 않고 import sys를 통해서 값을 받아 올 수 있다. testcase는 기존의 input으로 작성해도 런타임, 시간초과가 일어 나지 않는다.

testcase T변수를 input이 아닌 sys.stdin.readline()으로 작성하면 아래와 같다.

import sys
# T = int(input())
T = int(sys.stdin.readline().strip())  # strip()함수를 사용함으로 개행문자 /n을 제거할 수 있다.
for i in range(T):
    A, B = map(int, sys.stdin.readline().split())
    print(A+B)

아래는 참고하면 좋은 글이다. 

 

[Python 문법] 파이썬 입력 받기(sys.stdin.readline)

파이썬으로 코딩 테스트를 준비한다면, 반드시 알아야 할 입력방식인 sys.stdin.readline()에 대한 정리 입니다.

velog.io

 

728x90

'🧠Algorithm > Baekjoon💡' 카테고리의 다른 글

💡3052번  (0) 2023.12.22
💡10951번  (1) 2023.12.17
💡15552번  (0) 2023.12.16
💡25314번  (0) 2023.12.16
💡2480번  (0) 2023.12.08
Comments