Home [BOJ 5565] 영수증
Post
Cancel

[BOJ 5565] 영수증

영수증 (5565번)

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

풀이방법

  • 첫번째 줄에는 10권의 총 가격이 주어진다고 하였으므로 두번째 줄부터 마지막 줄 까지의 합을 첫번째 값에서 빼주면 정답을 유추할 수 있다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int totalSum = Integer.parseInt(br.readLine());
        int sum = 0;
        for(int i=0; i<9; i++) {
            sum += Integer.parseInt(br.readLine());
        }

        System.out.println(totalSum - sum);
    }
}

This post is licensed under CC BY 4.0 by the author.

[BOJ 1037] 약수

[BOJ 1759] 암호 만들기

Comments powered by Disqus.