2 条题解
-
2
#include <iostream>//hetao3097453 using namespace std; int a[100][100],sum0,sum1; int main() { int n,m; cin >> n >> m; for(int i = 1;i <= n;i++) { for(int j = 1;j <= m;j++) { cin >> a[i][j]; if(a[i][j] % 2 == 0) { sum0++; } else { sum1++; } } } cout << sum1 << " " << sum0; return 0; }
-
1
第一步,先看题目,一眼看上去:
好难啊!!!
想了半天是动规呢?还是建树呢?于是,我就想到了用来解决这道世界难题题
#include <bits/stdc++.h> using namespace std; int main() { int n, m, ans1 = 0, ans2 = 0; vector<int> vec; cin >> n >> m; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { int x; cin >> x; vec.push_back(x); } } for (int i = 0; i < vec.size(); i++) (vec[i] % 2 == 1) ? ans1++ : ans2++; cout << ans1 << " " << ans2; }
- 1
信息
- ID
- 395
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 1
- 标签
- 递交数
- 72
- 已通过
- 52
- 上传者