728x90
반응형
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring> // memset 헤더
#include <string>
using namespace std;
// [백준 10824 c++ O] 네 수
// 문제:
// 접근: 숫자 이어붙히기 -> 문자열 문제 -> 문자열 수로 변환후 계산
// 질문:
// 시간복잡도: O(1) ,
// 풀이:
// 수가 커서 longlong 사용
int main()
{
ios::sync_with_stdio(false); // 계산시간 단축 // cin,scanf 같이 쓰면 오류
cin.tie(nullptr); cout.tie(nullptr);// 입출력 시간 단축 // 이것을 쓰면 scanf,printf섞어 쓰면 안됨
string a,b,c,d;
cin >> a >> b >> c >> d;
string s1 = a + b;
string s2 = c + d;
cout << stoll(s1) + stoll(s2) << '\n';
return 0;
}
|
cs |
반응형
'Algorithm_BOJ(백준) > 문자열' 카테고리의 다른 글
[백준 1152 c++ V] 단어의 개수 (0) | 2021.08.07 |
---|---|
[백준 11656 c++ O] 접미사 배열 (0) | 2021.08.07 |
[백준 11655 c++ O] ROT13 (0) | 2021.08.07 |
[백준 2743 c++ O] 단어 길이 재기 (0) | 2021.08.07 |
[백준 10820 c++ O] 문자열 분석 (0) | 2021.08.07 |