結果

問題 No.883 ぬりえ
ユーザー htensaihtensai
提出日時 2019-11-11 13:04:49
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 2,019 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 60,516 KB
最終ジャッジ日時 2023-10-13 08:00:13
合計ジャッジ時間 7,256 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,832 KB
testcase_01 AC 122 ms
56,168 KB
testcase_02 AC 123 ms
55,924 KB
testcase_03 AC 122 ms
55,900 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 122 ms
56,208 KB
testcase_08 AC 121 ms
56,212 KB
testcase_09 AC 121 ms
56,128 KB
testcase_10 AC 122 ms
56,420 KB
testcase_11 AC 121 ms
56,352 KB
testcase_12 AC 120 ms
56,120 KB
testcase_13 AC 118 ms
56,204 KB
testcase_14 WA -
testcase_15 AC 224 ms
60,516 KB
testcase_16 AC 178 ms
58,500 KB
testcase_17 AC 165 ms
56,208 KB
testcase_18 AC 122 ms
56,188 KB
testcase_19 WA -
testcase_20 AC 122 ms
55,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int size = (n + k - 1) / k;
		char[][] field = new char[size][size];
		for (int i = 0; i < size; i++) {
		    Arrays.fill(field[i], '.');
		}
		int count = 0;
		StringBuilder sb = new StringBuilder();
		sb.append(size).append("\n");
		for (int i = 0; i < size; i++) {
		    for (int j = 0; j < size; j++) {
		        if (((j >= i && (i + k - 1) % size >= j) || (i + k > size && (j >= i || (i + k - 1) % size >= j ))) && count < n) {
		            field[i][j] = '#';
		            count++;
		        }
		    }
		    sb.append(new String(field[i])).append("\n");
		}
		System.out.print(sb);
	}
}
0