728x90
반응형
풀이 :
문제 이해가 필요. 단순 계산 문제
A회사, B회사 수도 요금을 계산하고 더 작은 값을 출력함
public class Solution1284 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T;
T = sc.nextInt();
for (int tc = 1; tc <= T; tc++) {
int P = sc.nextInt(); // 9 -> A회사 리터당 9
int Q = sc.nextInt(); // 100 -> 20L 이하 요금 -> 기본 요금
int R = sc.nextInt(); // 20 -> 기준점
int S = sc.nextInt(); // 3 -> 리터당 3
int W = sc.nextInt(); // 10 -> 사용한 리터
int A = 0;
int B = 0;
A = P * W;
if (R > W) {
B = Q;
} else {
B = Q + (W - R) * S;
}
int result = Math.min(A, B);
System.out.println("#" + tc + " " + result);
}
}
}
728x90
반응형
'SWEA' 카테고리의 다른 글
swea 1926 [D2] 간단한 369게임 JAVA (0) | 2023.11.20 |
---|---|
swea 1859 [D2] 백만 장자 프로젝트 JAVA (0) | 2023.11.20 |
swea 1288 [D2] 새로운 불면증 치료법 JAVA (0) | 2023.11.20 |
swea 1285 [D2] 아름이의 돌 던지기 JAVA (0) | 2023.11.20 |
swea 1204 [D2] [S/W 문제해결 기본] 최빈수 구하기 JAVA (0) | 2023.11.20 |