본문 바로가기
Algorithm/Baekjoon

[백준] 11382번 : 꼬마 정민 - Java

by unknownomad 2023. 7. 18.

https://www.acmicpc.net/problem/11382

 

11382번: 꼬마 정민

첫 번째 줄에 A, B, C (1 ≤ A, B, C ≤ 1012)이 공백을 사이에 두고 주어진다.

www.acmicpc.net

 

 

풀이

import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
		
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long c = in.nextLong();
 
        System.out.println(a + b + c);
    }
}
  • int (4 bytes)보다 큰 값을 출력할 수도 있으므로 long (8 bytes) 타입 사용해 출력

 

Primitive type in Java

https://crunchify.com/java-tip-wherever-possible-try-to-use-primitive-types-instead-of-wrapper-classes/

댓글