[백준] 8370

당당·2023년 5월 28일
0

백준

목록 보기
136/179

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

📔문제

Byteland Airlines recently extended their aircraft fleet with a new model of a plane. The new acquisition has n1 rows of seats in the business class and n2 rows in the economic class. In the business class each row contains k1 seats, while each row in the economic class has k2 seats.

Write a program which:

  • reads information about available seats in the plane,
  • calculates the sum of all seats available in that plane,
  • writes the result.

📝입력

In the first and only line of the standard input there are four integers n1, k1, n2 and k2 (1 ≤ n1, k1, n2, k2 ≤ 1 000), separated by single spaces.


📺출력

The first and only line of the standard output should contain one integer - the total number of seats available in the plane.


📝예제 입력 1

2 5 3 20

📺예제 출력 1

70

🔍출처

Contest > Algorithmic Engagements > PA 2007 0-1번


🧮알고리즘 분류

  • 수학
  • 사칙연산

📃소스 코드

import java.util.Scanner;

public class Code8370 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n1=sc.nextInt();//비즈니스 석 행 수
        int k1=sc.nextInt();//각 행에 있는 좌석 수
        int n2=sc.nextInt();//이코노미 석 행 수
        int k2=sc.nextInt();//각 행의 좌석 수

        System.out.println(n1*k1+n2*k2);
    }
}


📰출력 결과


📂고찰

각 행의 수와, 행에 있는 좌석 수를 입력받아 각각을 곱해서 더하면 된다.

예를 들어, 4개의 행이 있는 비행기에 각 행마다 좌석이 4개씩 있다 하면 전체 좌석 수는 16개가 된다.

profile
MySQL DBA 신입 지원

0개의 댓글