結果

問題 No.988 N×Mマス計算(総和)
ユーザー toto
提出日時 2025-03-26 13:16:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 696 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 28,160 KB
実行使用メモリ 9,244 KB
最終ジャッジ日時 2025-03-26 13:16:40
合計ジャッジ時間 4,546 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 8 TLE * 1 -- * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d%d",&vertical,&horizontal);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |         scanf("%ld",&mod);
      |         ~~~~~^~~~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%c",&symbol);
      |         ~~~~~^~~~~~~~~~~~~~
main.cpp:17:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |                 scanf("%lld",&arrh[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   21 |                 scanf("%lld",&arrv[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
	// 縦の長さ・横の長さ
	int vertical,horizontal;
	scanf("%d%d",&vertical,&horizontal);
	// 割り
	long mod = 0;
	scanf("%ld",&mod);
	// 計算方法
	char symbol;
	scanf("%c",&symbol);
	
	long long arrv[vertical],arrh[horizontal];
	// 横配列の値
	for(int i = 0;i < horizontal;i ++){
		scanf("%lld",&arrh[i]);
	}
	// 縦配列の値
	for(int i = 0;i < vertical;i ++){
		scanf("%lld",&arrv[i]);
	}
	
	long long ans = 0;
	for(int i = 0;i < vertical;i ++){
		for(int j = 0;j < horizontal;j ++){
			if(symbol == '+'){
				ans += arrv[i] + arrh[j];
				ans %= mod;
			}else{
				ans *= arrv[i] * arrh[j];
				ans %= mod;
			}
		}
	}
	printf("%lld",ans);
}
0