結果

問題 No.988 N×Mマス計算(総和)
ユーザー parsee1053
提出日時 2020-06-22 00:46:41
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 89 ms / 2,000 ms
コード長 859 bytes
コンパイル時間 533 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-06 07:59:27
合計ジャッジ時間 1,778 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

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