#include <stdio.h>
int main()
{
unsigned long int n;
unsigned long int temp;
unsigned long int min_odd = 10000;
unsigned long int no_of_odd = 0;
unsigned long int sum = 0;
unsigned long int i;
scanf("%ld", &n);
if(n == 1)
{
scanf("%ld", &temp);
if(temp % 2 != 0)
{
printf("NIESTETY");
}
else
{
printf("%ld", temp);
}
}
else
{
for(i = 0; i < n; ++i)
{
scanf("%ld", &temp);
sum = sum + temp;
if(temp % 2 != 0)
{
no_of_odd++;
if(temp < min_odd)
{
min_odd = temp;
}
}
}
if(min_odd == 10000 || no_of_odd % 2 == 0)
{
printf("%ld", sum);
}
else
{
printf("%ld", sum - min_odd);
}
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | #include <stdio.h> int main() { unsigned long int n; unsigned long int temp; unsigned long int min_odd = 10000; unsigned long int no_of_odd = 0; unsigned long int sum = 0; unsigned long int i; scanf("%ld", &n); if(n == 1) { scanf("%ld", &temp); if(temp % 2 != 0) { printf("NIESTETY"); } else { printf("%ld", temp); } } else { for(i = 0; i < n; ++i) { scanf("%ld", &temp); sum = sum + temp; if(temp % 2 != 0) { no_of_odd++; if(temp < min_odd) { min_odd = temp; } } } if(min_odd == 10000 || no_of_odd % 2 == 0) { printf("%ld", sum); } else { printf("%ld", sum - min_odd); } } return 0; } |
English