• 문제 링크
https://www.acmicpc.net/problem/3279
• 풀이 코드
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int n = read();
float sum = 100, i = read();
while (n-- > 1) {
float j = read();
if (i > j) sum *= i / j;
i = j;
}
bw.write(String.format("%.2f", sum));
bw.flush();
}
private static int read() throws IOException {
int c, n = System.in.read() & 15;
while ((c = System.in.read()) > 32) n = (n << 3) + (n << 1) + (c & 15);
return n;
}
}
'Problem Solving > Baekjoon' 카테고리의 다른 글
[백준] 30350 Dviratininkas - Greedy / Java (0) | 2025.08.28 |
---|---|
[백준] 26753 OIJ - Greedy / Java (0) | 2025.08.27 |
[백준] 5747 Odd or Even - Greedy / Java (0) | 2025.08.25 |
[백준] 24197 Tabbtabbande - Greedy / Java (0) | 2025.08.24 |
[백준] 27588 Restaurant Opening - Brute Force / Java (0) | 2025.08.23 |
댓글