BOJ | 11021번

송치헌·2021년 6월 11일
0
post-thumbnail

Python 풀이

import sys

T = int(input())

for i in range(1, T+1):
    A, B = map(int, sys.stdin.readline().split())
    print(f"Case #{i}: {A+B}")

백준 15552번 문제 설명했듯이 반복문 안에서 입력을 여러번 받을 때
sys.stdin.readine().split()으로 입력을 받아주면 실행 속도가 빨라진다.
print(f"Case #{i}: {A+B})" 는 백준 2739번 문제에서 설명했듯 f-string을 이용하여 간편하게 코딩하였다.

C++ 풀이

#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n, A, B;
    cin >> n;
    for(int i=1;i<=n;i++) {
    	cin >> A >> B;
    	cout << "Case #" << i << ":" << " " << A + B << '\n';
    }
}
profile
https://oraange.tistory.com/ 여기에도 많이 놀러와 주세요

0개의 댓글