結果

問題 No.987 N×Mマス計算(基本)
ユーザー mmn15277198mmn15277198
提出日時 2020-02-25 21:28:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 834 bytes
コンパイル時間 509 ms
コンパイル使用メモリ 63,808 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-03 17:29:09
合計ジャッジ時間 1,543 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 4 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
	int a;//tate
	int b;//yoko
	char c;//+or*
	cin >> a >> b;
	
	if(a<0 || 100<a || b<0 || 100<b)exit(1); 
	long p[a+1][b+1];
	//cout << "check1" << endl;
	
	cin >> c;
	if(c !='+' && c != '*')exit(1);
	
	for(int i=1;i<=b;i++){
		cin >> p[0][i];
		//cout << "check2" << endl;
		//cout << p[0][i] << endl;
		if(p[0][i] < 0 || 1000000000 < p[0][i]){		
				exit(1);
		}
		//cout << "yoko" <<p[0][i] << endl;
	}
	
	for(int j=1;j<=a;j++){
		cin >> p[j][0];
		if(p[j][0]< 0 || 1000000000 < p[j][0]){
				exit(1);
		}
		//cout << "tate" << p[j][0] << endl;
	}
	
	for(int k=1;k<=a;k++){//tate
		for(int l=1;l<=b;l++){//yoko
			if(c=='+'){
				p[k][l]=p[k][0]+p[0][l];
			}
			if(c=='*'){
				p[k][l]=p[k][0]*p[0][l];
			}
			cout << p[k][l] << " ";
			if(l==b)cout << endl;
		}
	}
return 0;
}
0