結果

問題 No.988 N×Mマス計算(総和)
コンテスト
ユーザー rin204
提出日時 2020-07-01 14:16:37
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 675 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 739 ms
コンパイル使用メモリ 74,068 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-03-27 19:39:13
合計ジャッジ時間 3,182 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include<string>

using namespace std;
using ll = long long int;
int main(void){
    ll n, m, k, ans = 0;
    string ope;
    ll b = 0, a = 0, btmp;
    cin >> n >> m >> k >> ope;
    for(int i = 0; i < m; i++){
        cin >> btmp;
        b += btmp;
        b %= k;
    }
    if (ope == "*"){
        for(int i = 0; i < n; i++){
            cin >> a;
            ans += a * b;
            ans %= k;
        }
    }
    else{
        int atmp;
        for(int i = 0; i < n; i++){
            cin >> atmp;
            a += atmp;
            a %= k;
        }
        ans = a * m + b * n;
        ans %= k;
    }
    cout << ans << endl;
    return 0;


}
0