結果
問題 | No.942 プレゼント配り |
ユーザー | ei13337 |
提出日時 | 2019-12-01 00:49:02 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 1,384 bytes |
コンパイル時間 | 823 ms |
コンパイル使用メモリ | 83,016 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-14 09:47:17 |
合計ジャッジ時間 | 2,630 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <iostream> #include <vector> #include <stack> #include <queue> #include <algorithm> #include <set> #include <map> #include <iomanip> using namespace std; int main() { int n, k; cin >> n >> k; int m = n / k; if(n == 1) { cout << "Yes" << endl; cout << 1 << endl; return 0; } if((n % 2 == 0 && m % 2 == 1) || m == 1) { cout << "No" << endl; return 0; } cout << "Yes" << endl; if(k == 1) { for(int i = 0; i < n; i++) { if(i) cout << " "; cout << i + 1; } cout << endl; return 0; } if(m % 2 == 0) { for(int i = 0; i < k; i++) { for(int j = 0; j < m; j++) { if(j) cout << " "; if(j % 2 == 0) cout << j * k + 1 + i; else cout << (j + 1) * k - i; } cout << endl; } } else { for(int i = 0; i < k; i++) { int a = 1 + i; int b = (k + 1) + (k / 2 + i) % k; int c = (k + (k + 1 + k / 2) + 2 * k + 1) - a - b; cout << a << " " << b << " " << c; for(int j = 3; j < m; j++) { cout << " "; if(j % 2 == 0) cout << j * k + 1 + i; else cout << (j + 1) * k - i; } cout << endl; } } return 0; }