fork(16) download
  1. # include <bits/stdc++.h>
  2. using namespace std;
  3. # define fi cin
  4. # define fo cout
  5. int main(void)
  6. {
  7. int n;
  8. fi>>n;
  9. int g = 0,v,cnt = 0,ans = 0;
  10. while (n --)
  11. {
  12. int v;
  13. fi>>v;
  14. g = __gcd(g,v);
  15. if (v & 1) ++cnt;
  16. else ans += (cnt / 2) + 2 * (cnt & 1),cnt = 0;
  17. }
  18. ans += (cnt / 2) + 2 * (cnt & 1);
  19. fo << "YES\n";
  20. if (g == 1)
  21. fo << ans << '\n';
  22. else
  23. fo << "0\n";
  24. cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
  25. return 0;
  26. }
  27.  
Time limit exceeded #stdin #stdout 5s 15240KB
stdin
Standard input is empty
stdout
Standard output is empty