結果

問題 No.988 N×Mマス計算(総和)
ユーザー SSRS
提出日時 2020-08-29 07:46:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 108 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 71,652 KB
最終ジャッジ日時 2025-01-13 20:01:23
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
	int N, M, K;
	cin >> N >> M >> K;
	char op;
	cin >> op;
	vector<int> B(M);
	for (int i = 0; i < M; i++){
		cin >> B[i];
	}
	vector<int> A(N);
	for (int i = 0; i < N; i++){
		cin >> A[i];
	}
	long long sumA = 0;
	for (int i = 0; i < N; i++){
		sumA += A[i];
	}
	sumA %= K;
	long long sumB = 0;
	for (int i = 0; i < M; i++){
		sumB += B[i];
	}
	sumB %= K;
	if (op == '+'){
		cout << (sumA * M + sumB * N) % K << endl;
	}
	if (op == '*'){
		cout <<  sumA * sumB % K << endl;
	}
}
0