結果
| 問題 |
No.942 プレゼント配り
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-12-05 21:29:47 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 887 bytes |
| コンパイル時間 | 179 ms |
| コンパイル使用メモリ | 30,464 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-23 00:02:18 |
| 合計ジャッジ時間 | 2,191 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 12 WA * 6 |
ソースコード
// 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;
}
bal4u