알고리즘/백준
백준 1247 부호
고구마와 감자
2022. 12. 7. 22:01
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("-");
}
}
}