結果

問題 No.988 N×Mマス計算(総和)
ユーザー tokutarotokutaro
提出日時 2020-03-21 16:50:00
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 709 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 70,328 KB
実行使用メモリ 5,396 KB
最終ジャッジ日時 2023-09-20 12:17:02
合計ジャッジ時間 2,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int N,M,K;
    cin>>N>>M>>K;
    string op;
    cin >> op;
    vector<ll> vca, vcb;
    REP(i, M) {
        ll l;
        cin >> l;
        vcb.push_back(l);
    }
    REP(i, N) {
        ll l;
        cin >> l;
        vca.push_back(l);
    }
    ll suma = 0;
    REP(i, N) {
        suma = (suma + vca.at(i)) % K;
    }
    ll sumb = 0;
    REP(i, M) {
        sumb = (sumb + vcb.at(i)) % K;
    }
    if (op == "+") {
        cout << (M * suma + N * sumb) % K << endl;
    } else if (op == "*") {
        cout << (suma * sumb) % K << endl;
    }
    return 0;
}
0