본문 바로가기

Algorithm

C++(씨쁠쁠)(cplusplus) - 백준(baekjoon)(BaekJoon)코딩 15552번 : 빠른 A+B 답

반응형

ios::sync_with_stdio(false)

cin.tie(NULL) 이 두개를 이용해 입 출력 시간을 단축하는 문제입니다. 이 설명은 제 블로그에 cin,cout 시간초과 해결법을 보시면 됩니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>
using namespace std;
int main() {
    cin.tie(NULL); //cin 과 cout을 untie
    ios::sync_with_stdio(false); //동기화 되어 있는 <iostream>과 <stdio.h>사이의 동기화를 끊어줌으로써 <iostream>버퍼만 사용
    int T;
    int a, b;
    cin >> T;
    while (T--)
    {
        cin >> a >> b;
        cout << a + b << '\n';
    }
}

cs