結果
| 問題 |
No.401 数字の渦巻き
|
| コンテスト | |
| ユーザー |
monburan_0401
|
| 提出日時 | 2018-09-22 19:45:09 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 1,542 bytes |
| コンパイル時間 | 348 ms |
| コンパイル使用メモリ | 30,464 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 11:41:29 |
| 合計ジャッジ時間 | 1,176 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 30 |
ソースコード
#include <stdio.h>
int main(void){
int N;
int box[30][30] = {0};
int count = 1;
scanf("%d",&N);
int start = 0;
int end = N;
/*
// left to right
for(int i = 0; i < N; i++){
box[0][i] = count;
count++;
}
// douwn
for(int j = 1; j < N; j++){
box[j][N-1] = count;
count++;
}
// right to left
for(int k = N-2; k >= 0; k--){
box[N-1][k] = count;
count++;
}
// up
for(int l = N-2; l >= 1; l--){
box[l][0] = count;
count++;
}
*/
while(count <= N*N){
// left to right
for(int i = start; i < end; i++){
box[start][i] = count;
count++;
}
// douwn
for(int j = start + 1; j < end; j++){
box[j][end-1] = count;
count++;
}
// right to left
for(int k = end-2; k >= start; k--){
box[end-1][k] = count;
count++;
}
// up
for(int l = end-2; l >= start+1; l--){
box[l][start] = count;
count++;
}
start++;
end--;
}
// check
for(int a = 0; a < N; a++){
for(int b = 0; b < N; b++){
if(box[a][b] / 100 == 0){
printf("0");
if(box[a][b] / 10 == 0){
printf("0");
}
}
printf("%d ",box[a][b]);
}
printf("\n");
}
return 0;
}
monburan_0401