Notice
Recent Posts
Recent Comments
Link
«   2025/12   »
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 30 31
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 10824번 네 수 본문

YJ/C++

[백준/BOJ/C++] 10824번 네 수

Team DAON 2021. 11. 12. 15:52

[문제]

네 자연수 A, B, C, D가 주어진다. 이때, A와 B를 붙인 수와 C와 D를 붙인 수의 합을 구하는 프로그램을 작성하시오.

두 수 A와 B를 합치는 것은 A의 뒤에 B를 붙이는 것을 의미한다. 즉, 20과 30을 붙이면 2030이 된다.

[입력]

첫째 줄에 네 자연수 A, B, C, D가 주어진다. (1 ≤ A, B, C, D ≤ 1,000,000)

[출력]

A와 B를 붙인 수와 C와 D를 붙인 수의 합을 출력한다.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main() {
	string a, b, c, d;
	long long first, second;

	cin >> a >> b >> c >> d;

	first = stoull(a+b);
	second = stoull(c+d);

	long long result = first + second;
	cout << result;
}

[결과 화면]