結果

問題 No.988 N×Mマス計算(総和)
ユーザー Kome_soudou
提出日時 2022-05-21 18:58:57
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 168,160 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 12:04:27
合計ジャッジ時間 3,272 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t N, M, K;
	char op;
	cin >> N >> M >> K >> op;
	vector<int64_t> B(M);
	vector<int64_t> A(N);
	for(int64_t i = 0; i < M; i++) cin >> B[i];
	for(int64_t i = 0; i < N; i++) cin >> A[i];
	
	int64_t sa = 0;
	int64_t sb = 0;
	for(int64_t i = 0; i < N; i++) sa += A[i];
	for(int64_t i = 0; i < M; i++) sb += B[i];
	sa %= K;
	sb %= K;
	int64_t ans = 0;
	if(op == '+')
	{
		ans += M * sa;
		ans %= K;
		ans += N * sb;
		ans %= K;
	}
	else
	{
		ans += sa * sb;
		ans %= K;
	}
	cout << ans << endl;
	return 0;
}
0