#include <stdio.h>
int main () {
long long a, b, c, sum = 0;
scanf ("%lld %lld", &a, &b);
long long total = a * b + 1;
while (-- total && scanf("%lld", &c) != EOF) {
sum += c;
}
printf ("%lld", sum);
return 0;
} #include <stdio.h>
int main() {
int n, m;
if (scanf("%d %d", &n, &m) != 2 || 1 > n || 1 > m || n > 1000 || m > 1000) {
return 1;
}
int a;
long sum=0;
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < m; j += 1) {
if (scanf("%d", &a) != 1 ||1 > a || a > 1000000000) {
return 1;
}
sum += a;
}
}
printf("%ld", sum);
return 0;
} #include <iostream>
using namespace std;
#include <vector>
using ll = long long;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
vector<vector<ll>> v(n+1, vector<ll>(m+1, 0));
ll count = 0;
for(auto& row : v){
for(auto& val : row){
cin >> val;
count += val;
}
}
cout << count << endl;
}
using ll = long long;
int main() {
ll n, m, x, sum = 0;
cin >> n >> m;
for(int i = 0; i < n * m; i ++) cin >> x, sum += x;
cout << sum;
} import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt(), m = in.nextInt();
long sum = 0;
// 按照题目要求使用数组的做法
int[][] nums = new int[n][m];
for (int h=0; h<n; h++) {
for (int w=0; w<m; w++) {
nums[h][w] = in.nextInt();
}
}
for (int[] outside:nums) {
for (int inside:outside) {
sum+=inside;
}
}
/* 邪修版
for (int i=0; i<n; i++) {
for (int l=0; l<m; l++) {
sum += in.nextInt();
}
}
*/
System.out.println(sum);
}
} 还是邪修好