https://www.acmicpc.net/problem/1247
1247번: 부호
총 3개의 테스트 셋이 주어진다. 각 테스트 셋의 첫째 줄에는 N(1 ≤ N ≤ 100,000)이 주어지고, 둘째 줄부터 N개의 줄에 걸쳐 각 정수가 주어진다. 주어지는 정수의 절댓값은 9223372036854775807보다 작거
www.acmicpc.net
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
for (int i = 0; i < 3; i++) {
int N = Integer.parseInt(br.readLine());
BigInteger result = new BigInteger("0");
for (int j = 0; j < N; j++) {
BigInteger tmp = new BigInteger(br.readLine());
result = result.add(tmp);
}
if (result.equals(BigInteger.ZERO)) System.out.println("0");
else if (result.compareTo(BigInteger.ZERO) == 1) System.out.println("+");
else System.out.println("-");
}
}
}
'알고리즘 > 백준' 카테고리의 다른 글
백준 11023 더하기 3 (0) | 2022.12.07 |
---|---|
백준 3059 등장하지 않는 문자의 합 (0) | 2022.12.07 |
백준 2857 FBI (0) | 2022.12.07 |
백준 9295 주사위 (0) | 2022.12.07 |
백준 2783 삼각김밥 (0) | 2022.12.07 |