結果
問題 | No.1169 Row and Column and Diagonal |
ユーザー | ks2m |
提出日時 | 2020-08-14 21:39:16 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 279 ms / 2,000 ms |
コード長 | 604 bytes |
コンパイル時間 | 2,689 ms |
コンパイル使用メモリ | 76,176 KB |
実行使用メモリ | 57,428 KB |
最終ジャッジ日時 | 2024-10-10 14:41:22 |
合計ジャッジ時間 | 6,689 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 13 |
ソースコード
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()); } } }