๋ฐ์ํ
https://www.acmicpc.net/problem/12790
์ฝ๋
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(bf.readLine()); // ํ
์คํธ ์ผ์ด์ค์ ์
for(int i=0; i<T; i++) {
st = new StringTokenizer(bf.readLine());
int[] ability = new int[8]; // HP, MP ๊ณต, ๋ฐฉ, ์ฆ๊ฐ๋๋ HP, MP, ๊ณต, ๋ฐฉ
for(int j=0; j<8; j++) {
ability[j] = Integer.parseInt(st.nextToken());
}
// ์ต์ข
๋ฅ๋ ฅ์น = ๊ธฐ๋ณธ ๋ฅ๋ ฅ์น + ์ฅ๋น ๋ฅ๋ ฅ์น
for(int j=0; j<4; j++) {
ability[j] += ability[j+4];
}
// HP, MP๊ฐ 1๋ณด๋ค ์์๊ฒฝ์ฐ 1๋ก ๊ฐ์ฃผ, ๊ณต๊ฒฉ๋ ฅ์ 0๋ณด๋ค ์์๊ฒฝ์ฐ 0์ผ๋ก ๊ฐ์ฃผ
ability[0] = (ability[0] < 1) ? 1 : ability[0];
ability[1] = (ability[1] < 1) ? 1 : ability[1];
ability[2] = (ability[2] < 0) ? 0 : ability[2];
// ์ ํฌ๋ ฅ = 1 * (HP) + 5 * (MP) + 2 * (๊ณต๊ฒฉ๋ ฅ) + 2 * (๋ฐฉ์ด๋ ฅ)
int result = ability[0] + (ability[1]*5) + (ability[2]*2) + (ability[3]*2);
System.out.println(result);
}
bf.close();
}
}
ํ์ด
๋ฌธ์ ์ ๋ฐ๋ผ์ ๊ทธ๋๋ก ๊ตฌํํ๋ฉด ๋๋ค!
ํด๋น ์ ๋ณด๋ฅผ ๋ฐฐ์ด๋ก ์ ๋ ฅ๋ฐ๊ณ , ์ฃผ์ด์ง ์กฐ๊ฑด์๋ฐ๋ผ ๊ตฌํ..
๋ฐ์ํ
'Algorithm' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SW Expert Academy] - (D3)9317. ์์ฐฌ์ด์ ๋ฐ์์ฐ๊ธฐ (0) | 2020.05.25 |
---|---|
[SW Expert Academy] - (D3)4751. ๋ค์์ด์ ๋ค์ด์๋ชฌ๋ ์ฅ์ (0) | 2020.05.25 |
[๋ฐฑ์ค] 10409๋ฒ: ์๋ฒ (0) | 2020.05.20 |
[๋ฐฑ์ค] 10539๋ฒ: ์๋น์ด์ ์์ด (0) | 2020.05.20 |
[๋ฐฑ์ค] 2909๋ฒ: ์บ๋ ๊ตฌ๋งค(๊ตฌํ) (0) | 2020.05.18 |
๋๊ธ