798 C. Mike and gcd problem
2017-04-25 09:49
357 查看
#include<iostream> #include<vector> #include<string> #include<set> #include<map> #include<algorithm> #include<queue> using namespace std; int gcd(int a, int b){ while (a > 0){ int c = b%a; b = a; a = c; } return b; } int main(){ int n; while (cin >> n){ vector<int> demo(n); int temp_c = 0; int amount = 0; int g = 0; for (int i = 0; i < n; i++){ cin >> demo[i]; g = gcd(g, demo[i]); if (demo[i] % 2) temp_c++; else { amount += (temp_c / 2) + 2 * (temp_c % 2); temp_c = 0; } } amount += (temp_c / 2) + 2 * (temp_c % 2); cout << "YES" << endl; if (g == 1) cout << amount << endl; else cout << "0" << endl; } return 0; }
相关文章推荐
- CF#798 C. Mike and gcd problem(思维)
- CF --- 798 C Mike and gcd problem 【思维】
- Codeforces 798C:Mike and gcd problem【数论+贪心】
- Codeforces 798C:Mike and gcd problem
- C. Mike and gcd problem
- Codeforces Round #410 (Div. 2) C. Mike and gcd problem 贪心
- C. Mike and gcd problem
- 【推导】Codeforces Round #410 (Div. 2) C. Mike and gcd problem
- Codeforces Round #410 (Div. 2)C. Mike and gcd problem(数论)
- Mike and gcd problem
- Codeforces Round #410 (Div.2) C.Mike and gcd problem-数学
- codeforces 798C - Mike and gcd problem 贪心
- Codefroces 410 C. Mike and gcd problem
- Codeforces-798C-Mike and gcd problem(贪心+数论)
- Mike and gcd problem-codeforces-Round 410 Div2-C
- 【算法系列学习】codeforces C. Mike and gcd problem
- 【codeforces 798C】Mike and gcd problem
- D - Mike and gcd problem
- C. Mike and gcd problem-递推或者贪心
- Mike and gcd problem Codeforces Round #410 (Div. 2)