#include <cstdio> using namespace std; int main() { int n, t, s = 0; bool p = true; scanf("%d", &n); for (int i=0;i<n;i++) { scanf("%d", &t); p ^= (t % 2 != 0); if (p) { if (s == 0) s = 1; else s = (s*2)%1000000007; } } if (!p) s = 0; printf("%d", s); }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #include <cstdio> using namespace std; int main() { int n, t, s = 0; bool p = true; scanf("%d", &n); for (int i=0;i<n;i++) { scanf("%d", &t); p ^= (t % 2 != 0); if (p) { if (s == 0) s = 1; else s = (s*2)%1000000007; } } if (!p) s = 0; printf("%d", s); } |