結果

問題 No.1587 012 Matrix
ユーザー ks2mks2m
提出日時 2021-07-08 22:36:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 175 ms / 1,000 ms
コード長 827 bytes
コンパイル時間 2,527 ms
コンパイル使用メモリ 72,096 KB
実行使用メモリ 56,944 KB
最終ジャッジ日時 2023-09-14 05:12:28
合計ジャッジ時間 6,886 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
56,176 KB
testcase_01 AC 110 ms
56,164 KB
testcase_02 AC 117 ms
56,276 KB
testcase_03 AC 112 ms
56,692 KB
testcase_04 AC 105 ms
56,112 KB
testcase_05 AC 104 ms
56,304 KB
testcase_06 AC 106 ms
56,012 KB
testcase_07 AC 117 ms
56,360 KB
testcase_08 AC 117 ms
56,252 KB
testcase_09 AC 119 ms
56,044 KB
testcase_10 AC 117 ms
55,908 KB
testcase_11 AC 123 ms
56,136 KB
testcase_12 AC 123 ms
56,440 KB
testcase_13 AC 126 ms
56,140 KB
testcase_14 AC 140 ms
55,972 KB
testcase_15 AC 147 ms
56,360 KB
testcase_16 AC 163 ms
56,224 KB
testcase_17 AC 165 ms
56,440 KB
testcase_18 AC 175 ms
55,964 KB
testcase_19 AC 168 ms
56,164 KB
testcase_20 AC 167 ms
56,944 KB
testcase_21 AC 163 ms
56,312 KB
testcase_22 AC 110 ms
56,108 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();

		char[][] s = new char[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(s[i], '0');
		}
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				s[i][j] = '2';
			}
			if (i < n / 2) {
				s[i][i] = '1';
			}
		}
		for (int i = 0; i < n; i++) {
			System.out.println(s[i]);
		}

//		for (int i = 0; i < n; i++) {
//			int sum = 0;
//			for (int j = 0; j < n; j++) {
//				sum += s[i][j] - '0';
//			}
//			System.out.println(sum);
//		}
//		for (int j = 0; j < n; j++) {
//			int sum = 0;
//			for (int i = 0; i < n; i++) {
//				sum += s[i][j] - '0';
//			}
//			System.out.println(sum);
//		}
	}
}
0