結果
問題 | No.48 ロボットの操縦 |
ユーザー |
![]() |
提出日時 | 2015-10-31 20:15:01 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 23 ms / 5,000 ms |
コード長 | 1,965 bytes |
コンパイル時間 | 2,448 ms |
コンパイル使用メモリ | 106,552 KB |
実行使用メモリ | 23,856 KB |
最終ジャッジ日時 | 2024-11-21 18:30:11 |
合計ジャッジ時間 | 3,790 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 25 |
コンパイルメッセージ
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 AbsX = Math.Abs(X);int AbsY = Math.Abs(Y);//回転回数int KaitenCnt = 0;if (Y < 0) KaitenCnt = 2;else if (AbsX > 0) KaitenCnt = 1;//移動回数int MoveCnt = 0;//Y座標に移動if (AbsY > 0) {MoveCnt += AbsY / L;if (AbsY % L > 0) MoveCnt++;}//X座標に移動if (AbsX > 0) {MoveCnt += AbsX / L;if (AbsX % L > 0) MoveCnt++;}Console.WriteLine(KaitenCnt + MoveCnt);}}