题目:http://acm.hdu.edu.cn/showproblem.php?pid=2560
AC代码(C++):
#include <iostream> #include <queue> #include <set> #include <string> #include <algorithm> #include <string.h> #include <math.h> #define INF 0x3f3f3f3f #define eps 1e-8 typedef unsigned long long ULL; using namespace std; int n, m; int main() { int t; cin >> t; while (t--) { cin >> n >> m; int ans = 0; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { int tmp; cin >> tmp; if (tmp == 1)ans++; } } cout << ans << endl; } //system("pause"); }总结: 水题.