結果

問題 No.988 N×Mマス計算(総和)
ユーザー TsubaMukku
提出日時 2020-02-14 22:29:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 662 bytes
コンパイル時間 1,330 ms
コンパイル使用メモリ 168,812 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-06 07:19:01
合計ジャッジ時間 2,562 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 4 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
   int n, m, k;
   cin >> n >> m >> k;
   
   char op;
   cin >> op;
   
   vector<long long> b(m);
   for (int i = 0; i < m; i++) cin >> b[i];
   
   long long sumOfB = accumulate(b.begin(), b.end(), 0);
   
   vector<long long> a(n);
   for (int i = 0; i < n; i++) cin >> a[i];
   
   long long ans = 0;
   
   if (op == '+'){
       for (int i = 0; i < n; i++){
           ans += (m * a[i] + sumOfB);
           ans %= k;
       }
   }
   else{
       for (int i = 0; i < n; i++){
           ans += (a[i] * sumOfB);
           ans %= k;
       }
   }
   cout << ans << endl;
}
0