結果

問題 No.988 N×Mマス計算(総和)
ユーザー parsee1053parsee1053
提出日時 2020-06-22 00:46:41
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 584 ms
コンパイル使用メモリ 73,700 KB
実行使用メモリ 4,748 KB
最終ジャッジ日時 2023-09-20 12:40:22
合計ジャッジ時間 2,009 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 24 ms
4,376 KB
testcase_11 AC 38 ms
4,376 KB
testcase_12 AC 63 ms
4,616 KB
testcase_13 AC 29 ms
4,376 KB
testcase_14 AC 27 ms
4,380 KB
testcase_15 AC 25 ms
4,376 KB
testcase_16 AC 52 ms
4,376 KB
testcase_17 AC 64 ms
4,384 KB
testcase_18 AC 35 ms
4,376 KB
testcase_19 AC 59 ms
4,380 KB
testcase_20 AC 87 ms
4,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  char op;
  cin >> op;
  vector<ll> b(m);
  for (int i = 0; i < m; ++i) {
    cin >> b[i];
  }
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll bsum = 0;
  for (int i = 0; i < m; ++i) {
    bsum += b[i];
    bsum %= k;
  }
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    ll res = 0;
    if (op == '+') {
      res = (m * a[i]) % k;
      res = (res + bsum) % k;
    } else {
      res = a[i];
      res = (res * bsum) % k;
    }
    ans = (ans + res) % k;
  }
  cout << ans << endl;
  return 0;
}
0