結果

問題 No.883 ぬりえ
ユーザー bal4ubal4u
提出日時 2019-09-14 05:59:57
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 1,699 ms
コンパイル使用メモリ 29,944 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 12:23:21
合計ジャッジ時間 4,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 1 ms
4,380 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
4,384 KB
testcase_12 WA -
testcase_13 AC 1 ms
4,376 KB
testcase_14 WA -
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 1 ms
4,376 KB
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

// yukicoder 883 ぬりえ
// 2019.9.14 bal4u

#include <stdio.h>
#include <string.h>

#if 1
int getchar_unlocked(void);
int putchar_unlocked(int c);
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif

int in() {   // 非負整数の入力
	int n = 0; int c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

void out(int n) { // 非負整数の表示(出力)
	int i; char b[30];

	if (!n) pc('0');
	else {
		i = 0; while (n) b[i++] = n % 10 + '0', n /= 10;
		while (i--) pc(b[i]);
	}
	pc('\n');
}
void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

int M;
char A[1003][1003];

int main()
{
	int r, c, a, s, N, K;
	
	N = in(), K = in();
	M = ((N-1)/(K*K) + 1)*K;
	memset(A, '.', sizeof(A));
	for (r = 0; r < M; r++) A[r][M] = 0;
	a = N % (K*K);
	if (a == 0) s = M; else s = M-K;
	for (r = 0; r < s; r+=K) {
		int rr, cc;
		for (rr = 0; rr < K; rr++) for (cc = 0; cc < K; cc++) A[rr+r][cc+r] = '#';
	}
	for (r = M-K; r < M && a; r++) for (c = M-K; c < M; c++) {
		A[r][c] = '#';
		if (--a == 0) break;
	}
	out(M);
	for (r = 0; r < M; r++) outs(A[r]);
	return 0;
}
0