1247번 - 부호
using System;
class test{
static void Main(){
long n = Convert.ToInt64(Console.ReadLine());
long[] a = new long[n];
long plus = 0;
for(long i = 0; i < n; i++){
a[i] = Convert.ToInt64(Console.ReadLine());
plus += a[i];
}
if(plus > 0)
Console.WriteLine("+");
else if(plus < 0)
Console.WriteLine("-");
else
Console.WriteLine("0");
plus = 0;
long k = Convert.ToInt64(Console.ReadLine());
long[] b = new long[k];
for(long i = 0; i < k; i++){
b[i] = Convert.ToInt64(Console.ReadLine());
plus += b[i];
long m = Convert.ToInt64(Console.ReadLine());
long[] c = new long[m];
for(long i = 0; i < m; i++){
c[i] = Convert.ToInt64(Console.ReadLine());
plus += c[i];
주어진 정수 각각이 64-bit int라고 해서 수들의 합도 64-bit int인 것은 아닙니다.
댓글을 작성하려면 로그인해야 합니다.
hong1214 1년 전
using System;
class test{
static void Main(){
long n = Convert.ToInt64(Console.ReadLine());
long[] a = new long[n];
long plus = 0;
for(long i = 0; i < n; i++){
a[i] = Convert.ToInt64(Console.ReadLine());
plus += a[i];
}
if(plus > 0)
Console.WriteLine("+");
else if(plus < 0)
Console.WriteLine("-");
else
Console.WriteLine("0");
plus = 0;
long k = Convert.ToInt64(Console.ReadLine());
long[] b = new long[k];
for(long i = 0; i < k; i++){
b[i] = Convert.ToInt64(Console.ReadLine());
plus += b[i];
}
if(plus > 0)
Console.WriteLine("+");
else if(plus < 0)
Console.WriteLine("-");
else
Console.WriteLine("0");
plus = 0;
long m = Convert.ToInt64(Console.ReadLine());
long[] c = new long[m];
for(long i = 0; i < m; i++){
c[i] = Convert.ToInt64(Console.ReadLine());
plus += c[i];
}
if(plus > 0)
Console.WriteLine("+");
else if(plus < 0)
Console.WriteLine("-");
else
Console.WriteLine("0");
}
}