SSONG Cloud
[SWEA] 1284 수도 요금 경쟁 본문
반응형
import java.util.Scanner;
import java.io.FileInputStream;
class Solution
{
static int feeA(int P, int W) {
return P*W;
}
static int feeB(int Q, int R, int S, int W) {
if(W <= R) {
return Q;
}else {
return Q + S*(W - R);
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T = Integer.parseInt(sc.nextLine());
int P,Q,R,S,W;
int A, B;
for(int i = 1; i <= T; i++) {
P = sc.nextInt();
Q = sc.nextInt();
R = sc.nextInt();
S = sc.nextInt();
W = sc.nextInt();
A = feeA(P, W);
B = feeB(Q, R, S, W);
System.out.println("#" + i + " " + ((A > B) ? B : A));
}
}
}
반응형
'Algorithm > SW Expert Academy' 카테고리의 다른 글
[SWEA] 2005 파스칼의 삼각형 (0) | 2021.01.24 |
---|---|
[SWEA] 1974 수도쿠 검증 (0) | 2021.01.24 |
[SWEA] 간단한 369게임 (0) | 2021.01.24 |
[SWEA] 1204 최빈수 구하기 (0) | 2021.01.24 |
[SWEA] 1289 원재의 메모리 복구하기 (0) | 2021.01.24 |
Comments