// Kieszonkowe.cpp : Defines the entry point for the console application. // // #include "stdafx.h" #include <stdio.h> int main(int argc, char * argv[]) { // freopen("sample_input.txt", "r", stdin); // freopen("sample_output.txt", "w", stdout); int iCnt, iNom, iSmallestOdd, iSum = 0; bool fOddKnown = false; scanf("%d", &iCnt); for (int i = 0; i < iCnt; ++i) { scanf("%d", &iNom); iSum += iNom; if (iNom & 1) if (!fOddKnown || iNom < iSmallestOdd) { iSmallestOdd = iNom; fOddKnown = true; } } if (iSum & 1) iSum -= iSmallestOdd; if (iSum) printf("%d", iSum); else printf("NIESTETY"); 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 | // Kieszonkowe.cpp : Defines the entry point for the console application. // // #include "stdafx.h" #include <stdio.h> int main(int argc, char * argv[]) { // freopen("sample_input.txt", "r", stdin); // freopen("sample_output.txt", "w", stdout); int iCnt, iNom, iSmallestOdd, iSum = 0; bool fOddKnown = false; scanf("%d", &iCnt); for (int i = 0; i < iCnt; ++i) { scanf("%d", &iNom); iSum += iNom; if (iNom & 1) if (!fOddKnown || iNom < iSmallestOdd) { iSmallestOdd = iNom; fOddKnown = true; } } if (iSum & 1) iSum -= iSmallestOdd; if (iSum) printf("%d", iSum); else printf("NIESTETY"); return 0; } |