結果

問題 No.1169 Row and Column and Diagonal
ユーザー ks2mks2m
提出日時 2020-08-14 21:39:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 240 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 4,295 ms
コンパイル使用メモリ 75,584 KB
実行使用メモリ 46,784 KB
最終ジャッジ日時 2024-04-18 21:14:50
合計ジャッジ時間 8,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
40,176 KB
testcase_01 AC 117 ms
41,564 KB
testcase_02 AC 117 ms
41,388 KB
testcase_03 AC 101 ms
40,132 KB
testcase_04 AC 123 ms
41,792 KB
testcase_05 AC 115 ms
41,116 KB
testcase_06 AC 152 ms
41,340 KB
testcase_07 AC 172 ms
42,292 KB
testcase_08 AC 188 ms
42,312 KB
testcase_09 AC 197 ms
43,948 KB
testcase_10 AC 240 ms
46,772 KB
testcase_11 AC 234 ms
46,520 KB
testcase_12 AC 225 ms
46,196 KB
testcase_13 AC 228 ms
46,680 KB
testcase_14 AC 236 ms
46,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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();

		int[][] a = new int[n][n];
		for (int i = 1; i <= n; i++) {
			int x = i - 1;
			int y = i - 1 + n;
			for (int j = 0; j < n; j++) {
				a[x % n][y % n] = i;
				x++;
				y--;
			}
		}
		for (int i = 0; i < n; i++) {
			StringBuilder sb = new StringBuilder();
			for (int j = 0; j < n; j++) {
				sb.append(a[i][j]).append(' ');
			}
			sb.deleteCharAt(sb.length() - 1);
			System.out.println(sb.toString());
		}
	}
}
0