#include <iostream> using namespace std; bool is_odd( int n ) { return (n % 2) == 1; } int main() { ios_base::sync_with_stdio( false ); int cnt = 0; cin >> cnt; int sum = 0; int min_odd = 1001; int num_odd = 0; for( int i = 0; i < cnt; ++i ) { int banknote = 0; cin >> banknote; if( is_odd( banknote ) ) { num_odd += 1; min_odd = min( min_odd, banknote ); } sum += banknote; } if( is_odd( num_odd ) ) { sum -= min_odd; } if( sum ) { cout << sum << "\n"; } else { cout << "NIESTETY\n"; } }
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 | #include <iostream> using namespace std; bool is_odd( int n ) { return (n % 2) == 1; } int main() { ios_base::sync_with_stdio( false ); int cnt = 0; cin >> cnt; int sum = 0; int min_odd = 1001; int num_odd = 0; for( int i = 0; i < cnt; ++i ) { int banknote = 0; cin >> banknote; if( is_odd( banknote ) ) { num_odd += 1; min_odd = min( min_odd, banknote ); } sum += banknote; } if( is_odd( num_odd ) ) { sum -= min_odd; } if( sum ) { cout << sum << "\n"; } else { cout << "NIESTETY\n"; } } |