Baekjoon/python
[백준 15552번] 빠른 A+B
Yo-mi
2022. 4. 20. 13:20
import sys
T=int(input())
for i in range(1,T+1):
num1,num2=map(int,sys.stdin.readline().split())
print(num1+num2)
for문에서 입출력 방식이 느리면 한 두줄이 아닌 여러줄을 입력받거나 출력할 때 시간 초과가 날 수 있다.
그러므로 input 대신 sys.stdin.readline을 사용해야 한다.
sys.stdin.readline을 사용하기 위해서는 먼저 sys를 import 해주어야한다는 점을 잊지말자.
문제: 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