1. 문제

2. 접근방법
해당 문제는 데이터 범위에 대한 이해도를 바탕으로한다.
입력받는 값을 int 자료형으로 받을 경우 int형의 범위보다 큰 수의 경우 Overflow가 발생한다.
그러므로 더 큰 정수형의 범위를 받는 long long 자료형을 사용해야한다.
kotlin의 경우 long 자료형이 64bit인 long long 으로 설정되어 있으므로 long 자료형을 사용하면 된다.
유형 이름 | 바이트 | 값의 범위 |
sort | 2 Byte | -32,768 ~ 32,767 |
unsigned sort | 4 Byte | 0 ~ 65,535 |
int | 4 Byte | -2,147,483,648 ~ 2,147,483,647 |
unsigned int | 4 Byte | 0 ~ 4,294,967,295 |
long | 4 Byte | -2,147,483,648 ~ 2,147,483,647 |
unsigned long | 4 Byte | 0 ~ 4,294,967,295 |
long long | 8 Byte | –9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 |
unsigned long long | 8 Byte | 0 ~ 18,446,744,073,709,551,615 |
_int8 | 1 Byte | -128 ~ 127 |
_int16 | 2 Byte | -32,768 ~ 32,767 |
_int32 | 4 Byte | -2,147,483,648 ~ 2,147,483,647 |
_int64 | 8 Byte | -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 |
3. 정답
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.* | |
fun main() = with(Scanner(System.`in`)) { | |
print(nextLong() + nextLong() + nextLong()) | |
} |
https://www.acmicpc.net/problem/11382
11382번: 꼬마 정민
첫 번째 줄에 A, B, C (1 ≤ A, B, C ≤ 1012)이 공백을 사이에 두고 주어진다.
www.acmicpc.net
'알고리즘' 카테고리의 다른 글
백준 2745번 - 진법 변환 (0) | 2023.06.23 |
---|---|
백준 2563번 - 색종이 (0) | 2023.06.23 |
백준 1316번 - 그룹 단어 체커 (0) | 2023.06.22 |
백준 15552번 - 빠른 A+B (0) | 2023.06.20 |
백준 1008번 - A/B의 결과는? (0) | 2023.06.19 |