https://www.acmicpc.net/problem/12790
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
while (T-- > 0) {
StringTokenizer st = new StringTokenizer(br.readLine());
int hp = Integer.parseInt(st.nextToken());
int mp = Integer.parseInt(st.nextToken());
int attack = Integer.parseInt(st.nextToken());
int defense = Integer.parseInt(st.nextToken());
int hp1 = Integer.parseInt(st.nextToken());
int mp1 = Integer.parseInt(st.nextToken());
int attack1 = Integer.parseInt(st.nextToken());
int defense1 = Integer.parseInt(st.nextToken());
int finalHp = (hp + hp1) < 1 ? 1 : hp + hp1;
int finalMp = (mp + mp1) < 1 ? 1 : mp + mp1;
int finalAttack = (attack + attack1) < 0 ? 0 : attack + attack1;
int finalDefense = defense + defense1;
System.out.println(finalHp + 5 * finalMp + finalAttack * 2 + finalDefense * 2);
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
백준 1284 집주소 (0) | 2022.12.09 |
---|---|
백준 5523 경기결과 (0) | 2022.12.09 |
백준 2921 도미노 (0) | 2022.12.08 |
백준 1598 꼬리를 무는 숫자 나열 (0) | 2022.12.08 |
백준 5988 홀수일까 짝수일까 (0) | 2022.12.07 |