結果
問題 |
No.401 数字の渦巻き
|
ユーザー |
![]() |
提出日時 | 2016-09-26 20:23:24 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 25 ms / 2,000 ms |
コード長 | 2,193 bytes |
コンパイル時間 | 936 ms |
コンパイル使用メモリ | 115,136 KB |
実行使用メモリ | 26,008 KB |
最終ジャッジ日時 | 2024-11-18 15:14:13 |
合計ジャッジ時間 | 2,642 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static long N = long.Parse(Console.ReadLine()); static void Main() { int[,] masu = new int[N, N]; //左=0 int muki = 0; int x = 0, y = 0; for(int i = 0; i < N * N; i++) { masu[x, y] = i + 1; switch (muki) { case 0: if (x + 1 < N ) { if (masu[x + 1, y] == 0) { x++; break; } } muki++; y++; break; case 1: if (y + 1 < N ) { if (masu[x, y + 1] == 0) { y++; break; } } muki++; x--; break; case 2: if (x - 1 >= 0 ) { if (masu[x - 1, y] == 0) { x--; break; } } muki++; y--; break; case 3: if (y - 1 >= 0) { if (masu[x , y-1] == 0) { y--; break; } } muki=0; x++; break; } } for(int i = 0; i < N; i++) { string s = ""; for(int j = 0; j < N; j++) { if (j == N - 1) { s+= string.Format("{0:D3}", masu[j, i]); } else { s += string.Format("{0:D3}", masu[j, i])+" "; } } Console.WriteLine(s); } } }