Post

[BaekJoon] 31610번 - 飴の袋詰め (Drops Packing) [Java][C++]

[BaekJoon] 31610번 - 飴の袋詰め (Drops Packing) [Java][C++]

문제 링크


1. 문제 풀이


$1$ 개에 $A$ 엔인 사탕 $B$ 개와 $C$ 엔인 봉투의 가격의 총 합으로 $A \times B + C$ 로 간단하게 구할 수 있다.


2. 코드


1. 풀이 [Java]

1
2
3
4
5
6
7
8
9
10
11
12
13
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        int A = Integer.parseInt(br.readLine());
        int B = Integer.parseInt(br.readLine());
        int C = Integer.parseInt(br.readLine());

        System.out.println(A * B + C);
    }
}


2. 풀이 [C++]

1
2
3
4
5
6
7
8
9
10
11
#include <bits/stdc++.h>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b + c;
}

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