結果

問題 No.942 プレゼント配り
ユーザー bal4ubal4u
提出日時 2019-12-05 21:29:47
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 29,520 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-24 15:51:52
合計ジャッジ時間 2,629 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// yuki 942 プレゼント配り
// 2019.12.5 bal4u

#include <stdio.h>

typedef long long ll;

int getchar_unlocked(void);
int putchar_unlocked(int c);
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

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

void out(int n) { // 非負整数の表示(出力)
	int i = 0; char b[30];
	while (n) b[i++] = n % 10 + '0', n /= 10;
	while (i--) pc(b[i]);
}

void outs(char *s) { while (*s) pc(*s++); pc('\n'); }

int main()
{
	int N, K, a, b, s, x, f;

	N = in(), K = in();
	s = N/K;
	if ((s & 1) || (ll)N*(N+1)%(2*K)) outs("No");
	else {
		outs("Yes");
		a = 1, b = N, s = N/K;
		while (K--) {
			f = 1, x = s; while (--x) {
				if (f) out(a++), pc(' '), f = 0;
				else   out(b--), pc(' '), f = 1;
			}
			out(b--), pc('\n');
		}
	}
	return 0;
}
0