반응형
문제
https://www.acmicpc.net/problem/26005
JAVA 코드
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int N = Integer.parseInt(br.readLine());
int result = N * N / 2;
if (N == 1) {
result = 0;
} else if (N % 2 == 1) {
result += 1;
}
bw.write(String.valueOf(result));
br.close();
bw.flush();
bw.close();
}
}
반응형
'Algorithm > 문제 풀이' 카테고리의 다른 글
[BAEKJOON_12865 - JAVA] 평범한 배낭 (0) | 2022.11.24 |
---|---|
[BAEKJOON_26042 - JAVA] 식당 입구 대기 줄 (0) | 2022.11.24 |
[BAEKJOON_26043 - JAVA] 식당 메뉴 (0) | 2022.11.23 |
[BAEKJOON_3055 - JAVA] 탈출 (0) | 2021.01.01 |
[BAEKJOON_1759 - JAVA] 암호 만들기 (0) | 2020.12.31 |