結果

問題 No.883 ぬりえ
ユーザー GrenacheGrenache
提出日時 2019-09-13 22:46:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,260 bytes
コンパイル時間 3,622 ms
コンパイル使用メモリ 75,596 KB
実行使用メモリ 58,060 KB
最終ジャッジ日時 2023-09-17 14:55:34
合計ジャッジ時間 8,205 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,640 KB
testcase_01 AC 129 ms
55,728 KB
testcase_02 AC 130 ms
55,984 KB
testcase_03 AC 133 ms
56,184 KB
testcase_04 AC 131 ms
55,628 KB
testcase_05 AC 132 ms
55,744 KB
testcase_06 AC 129 ms
55,804 KB
testcase_07 WA -
testcase_08 AC 131 ms
55,660 KB
testcase_09 WA -
testcase_10 AC 127 ms
55,660 KB
testcase_11 AC 133 ms
55,628 KB
testcase_12 AC 129 ms
55,744 KB
testcase_13 AC 128 ms
55,736 KB
testcase_14 AC 131 ms
55,732 KB
testcase_15 AC 174 ms
58,060 KB
testcase_16 AC 164 ms
56,176 KB
testcase_17 AC 161 ms
55,864 KB
testcase_18 AC 130 ms
55,720 KB
testcase_19 AC 128 ms
55,712 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;


public class Main_yukicoder883 {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int k = sc.nextInt();

		int nn = n / (k * k);
		int r = n - nn * (k * k);

		int rr = (int)Math.sqrt(r);
		if (r > rr * rr) {
			rr++;
		}
		
		int m = nn * k + rr;
		
		char[][] a = new char[m][m];
		for (int i = 0; i < m; i++) {
			Arrays.fill(a[i], '.');
		}
		
		for (int i = 0; i < nn; i++) {
			int xx = i * k;
			int yy = i * k;
			for (int j = 0; j < k; j++) {
				for (int jj = 0; jj < k; jj++) {
					a[xx + j][yy + jj] = '#';
				}
			}
		}
		
		int xx = nn * k;
		int yy = nn * k;
		int cnt = 0;
		out:
		for (int j = 0; j < rr; j++) {
			for (int jj = 0; jj < rr; jj++) {
				a[xx + j][yy + jj] = '#';
				cnt++;
				if (cnt >= r) {
					break out;
				}
			}
		}
		
		
		pr.println(m);
		for (int i = 0; i < m; i++) {
			pr.println(a[i]);
		}
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);
			
		solve();
			
		pr.close();
		sc.close();
	}

	static class Printer extends PrintWriter {
		Printer(OutputStream out) {
			super(out);
		}
	}
}
0