結果

問題 No.401 数字の渦巻き
ユーザー notetonousnotetonous
提出日時 2016-08-17 20:36:25
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 993 bytes
コンパイル時間 714 ms
コンパイル使用メモリ 25,636 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 14:40:46
合計ジャッジ時間 2,073 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
int N;
int map[31][31];
void print(){
  int i,j;
  for(i=1;i<=N;i++){
    for(j=1;j<=N;j++){
      if(map[i][j]<10)
	printf("00%d ",map[i][j]);
      else if(map[i][j]>=100)printf("%d ",map[i][j]);
      else printf("0%d ",map[i][j]);
    }
    printf("\n");
  }
}
int main(){
  int i,j;
  int x=1,y=1;
  int n;
  scanf("%d",&N);
  if(N==1){
    printf("001\n");
    return 0;
  }
  n=N;
  map[1][1]=1;
  i=1;
  for(j=1;j<n;j++){
    x++;
    i++;
    map[y][x]=i;
  }
  for(j=1;j<n;j++){
    y++;
    i++;
    map[y][x]=i;
  }
  for(j=1;j<n;j++){
    x--;
    i++;
    map[y][x]=i;
  }
  
  n=n-2;
  while(1){
    if(n<1)break;
    for(j=1;j<=n;j++){
      y--;
      i++;
      map[y][x]=i;
    }
    for(j=1;j<=n;j++){
      x++;
      i++;
      map[y][x]=i;
    }
    n--;
    if(n<1)break;
    for(j=1;j<=n;j++){
      y++;
      i++;
      map[y][x]=i;
    }
    for(j=1;j<=n;j++){
      x--;
      i++;
      map[y][x]=i;
    }
    n--;
  }
  print();
  return 0;
}
0