Recent Posts
Recent Comments
Archives
Today
Total
05-21 00:42
관리 메뉴

이것저것 잡동사니

[백준 문제] 15552번: 빠른 A+B 본문

컴퓨터공학/백준 문제

[백준 문제] 15552번: 빠른 A+B

Park Siyoung 2021. 7. 18. 14:33
반응형

문제 바로가기 : https://www.acmicpc.net/problem/15552

 

A+B문제(1000번)의 실행 시간, 정확하게는 입출력 시간을 줄이는 문제다.

main 함수의 가장 앞 부분에(사실 cout의 앞이라면 아무데나 써도 상관없다) 다음의 두 줄을 추가해준다.

ios::sync_with_stdio(false);
cin.tie(NULL);

endl 대신 개행문자(\n)를 사용하도록 하자. 문제에 쓰여진 대로 scanf, printf 등의 C스타일 입출력 함수는 이제 사용할 수 없다.

자세한 내용은 다음 글을 확인하자 : https://www.acmicpc.net/board/view/22716


소스코드

#include <iostream>

using namespace std;

int main(void) {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    
    int T;
    cin >> T;
    
    for (int test_case = 0; test_case < T; test_case++) {
        int A, B;
        cin >> A >> B;
        cout << A + B << '\n';
    }
    return 0;
}
반응형
Comments