文章
49
粉丝
90
获赞
90
访问
37.9k
- #include<iostream>
- #include<vector>
- using namespace std;
-
- bool is_all_even_or_all_odd(vector<int> v)
- {
- if (v.front() % 2 == 0)
- {
- for (auto t : v)
- {
- if (t % 2 != 0)
- {
- return false;
- }
- }
- }
- else
- {
- for (auto t : v)
- {
- if (t % 2 == 0)
- {
- return false;
- }
- }
- }
- return true;
- }
-
- int main()
- {
- int n;
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- int t;
- cin >> t;
- vector<int> v(t);
- for (int i = 0; i < t; i++)
- {
- int x;
- cin >> x;
- v[i] = x;
- }
- if (is_all_even_or_all_odd(v))
- {
- cout << "YES" << endl;
- }
- else
- {
- cout << "NO" << endl;
- }
- }
-
- return 0;
- }
登录后发布评论
暂无评论,来抢沙发