#include <cstdio> #include <vector> int main() { int originalSize; int counter = 0; int numberOfOnes = 0; scanf("%d", &originalSize); while (counter < originalSize) { int currentIndexSize; scanf("%d", ¤tIndexSize); if (currentIndexSize == 1) { numberOfOnes++; } counter++; } if (numberOfOnes > 1) { printf("%d\n", 0); } else if (numberOfOnes == 1) { printf("%d\n", 1); } else { printf("%d\n", 2); } printf("%d\n", 2); printf("%d %d\n", 1, 2); 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 | #include <cstdio> #include <vector> int main() { int originalSize; int counter = 0; int numberOfOnes = 0; scanf("%d", &originalSize); while (counter < originalSize) { int currentIndexSize; scanf("%d", ¤tIndexSize); if (currentIndexSize == 1) { numberOfOnes++; } counter++; } if (numberOfOnes > 1) { printf("%d\n", 0); } else if (numberOfOnes == 1) { printf("%d\n", 1); } else { printf("%d\n", 2); } printf("%d\n", 2); printf("%d %d\n", 1, 2); return 0; } |