#include <bits/stdc++.h> using namespace std; int n; int k; int a[1000000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; int ones = 0; for(int i = 0; i < n; i ++){ cin >> a[i]; if(a[i] == 1) ones ++; } if(ones == 0){ k = 2; } else if(ones == 1){ k = 1; } else k = 0; cout << k << "\n"; cout << 2 << "\n"; cout << 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 28 29 | #include <bits/stdc++.h> using namespace std; int n; int k; int a[1000000]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n; int ones = 0; for(int i = 0; i < n; i ++){ cin >> a[i]; if(a[i] == 1) ones ++; } if(ones == 0){ k = 2; } else if(ones == 1){ k = 1; } else k = 0; cout << k << "\n"; cout << 2 << "\n"; cout << 1 << " " << 2; return 0; } |