[백준/python] 15552번: 빠른 A+B

2019. 9. 21. 02:05코딩테스트 준비/백준알고리즘

문제링크: 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

 

sys.stdin.readline이란걸 알게됐다... 이제 계속 이거 써먹어야지

 

1차 시도

n = sys.stdin.readline().rstrip()
    
for i in range(0, int(n)):
    a,b = map(int, sys.stdin.readline().rstrip().split())
    print(f'{a+b}\n')

 

틀림..

일단 import sys부터 해야하고.

 

일단 이렇게 해서 맞았다

import sys

n = int(sys.stdin.readline())
    
for i in range(n):
    a,b = map(int, sys.stdin.readline().split())
    print(f'{a+b}')

참고로할건 print(f'{a+b}\n')으로 하면 틀림