結果
問題 |
No.48 ロボットの操縦
|
ユーザー |
![]() |
提出日時 | 2015-10-31 20:04:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,973 bytes |
コンパイル時間 | 873 ms |
コンパイル使用メモリ | 111,724 KB |
実行使用メモリ | 25,812 KB |
最終ジャッジ日時 | 2024-09-13 06:30:46 |
合計ジャッジ時間 | 2,396 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 WA * 1 |
コンパイルメッセージ
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.Generic; class Program { static string InputPattern = "InputX"; static List<string> GetInputList() { var WillReturn = new List<string>(); if (InputPattern == "Input1") { WillReturn.Add("0"); WillReturn.Add("2"); WillReturn.Add("1"); //2 //座標(0,0)から(0,2)へ移動させます。1回の前進あたり1距離進むことができます。 //初期状態で北を向いているため、向きを変えずに前進命令を2回行うことで到達できます。 } else if (InputPattern == "Input2") { WillReturn.Add("-7"); WillReturn.Add("15"); WillReturn.Add("7"); //5 //北向きに7距離の前進を2回、1距離の前進を1回行い、 //反時計回りに90度回転した後、7距離の前進を1回行います。 //合計5回の命令で到達できます。 } else { string wkStr; while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr); } return WillReturn; } static void Main() { List<string> InputList = GetInputList(); int X = int.Parse(InputList[0]); int Y = int.Parse(InputList[1]); int L = int.Parse(InputList[2]); int SousaCnt = 0; //移動先のY座標がマイナスだったら回転が一回必要 if (Y < 0) SousaCnt++; //Y座標に移動 int AbsY = Math.Abs(Y); if (AbsY > 0) { SousaCnt += AbsY / L; if (AbsY % L > 0) SousaCnt++; } //X座標に移動 int AbsX = Math.Abs(X); if (AbsX > 0) { SousaCnt++; //X座標の移動用の回転 SousaCnt += AbsX / L; if (AbsX % L > 0) SousaCnt++; } Console.WriteLine(SousaCnt); } }