1061 判断题 (15 分)
#include <iostream> using namespace std; const int maxn = 20; // const 不能忘,新学的技能 int arr[1 << maxn] = {0}, brr[1 << maxn] = {0}; // 表示数组的最大下标可以达到 2^maxn - 1 int main(){ int n, m; cin >> n >> m; for (int i = 0; i < m; i++){ cin >> arr[i]; } for (int j = 0; j < m; j++){ cin >> brr[j]; } int x, sum; while (n--){ sum = 0; for (int k = 0; k < m; k++){ cin >> x; if (x == brr[k]){ sum += arr[k]; } else{ continue; } } cout << sum << endl; } return 0; }