結果
問題 | No.883 ぬりえ |
ユーザー |
![]() |
提出日時 | 2019-09-13 22:22:29 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 28 ms / 2,000 ms |
コード長 | 612 bytes |
コンパイル時間 | 364 ms |
コンパイル使用メモリ | 54,748 KB |
実行使用メモリ | 7,296 KB |
最終ジャッジ日時 | 2024-07-04 10:34:30 |
合計ジャッジ時間 | 1,276 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include <iostream> using namespace std; int n, k; int ans[1005][1005]; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; int m = (n+k-1)/k; for(;m*m < n; m++); for(int i = 0; i < min(m, k); i++){ for(int j = 0; j < m; j++){ ans[j][(j+i)%m] = -1; } } for(int i = 0; i < m; i++){ for(int j = 0; j < m; j++){ if(ans[i][j] == -1){ if(n > 0) ans[i][j] = 1, n--; else ans[i][j] = 0; } } } cout << m << endl; for(int i = 0; i < m; i++){ for(int j = 0; j < m; j++){ if(ans[i][j]) cout << "#"; else cout << "."; } cout << endl; } return 0; }