結果

問題 No.48 ロボットの操縦
ユーザー funakoshi
提出日時 2019-06-21 10:41:45
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 2,389 bytes
コンパイル時間 3,547 ms
コンパイル使用メモリ 105,744 KB
実行使用メモリ 25,816 KB
最終ジャッジ日時 2024-12-24 09:51:03
合計ジャッジ時間 2,432 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace yukicoderTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string x = Console.ReadLine();
            string y = Console.ReadLine();
            string l = Console.ReadLine();
            int we = int.Parse(x);
            int ns = int.Parse(y);
            int forward = int.Parse(l);
            int posiwe = 0;
            int posins = 0;
            int command = 0;
            while (posiwe!=we||posins!=ns)
            {
                if (we < 0&&posiwe!=we)
                {
                    command++;
                    if (we - posiwe < forward)
                    {
                        posiwe = we;
                        command++;
                    }
                    else
                    {
                        posiwe = posiwe - forward;
                        command++;
                    }
                }
                else if (we > 0&&posiwe != we)
                {
                    command++;
                    if (we - posiwe < forward)
                    {
                        posiwe = we;
                        command++;
                    }
                    else
                    {
                        posiwe = posiwe + forward;
                        command++;
                    }
                }
                if (ns < 0 && posins != ns)
                {
                    command = command + 2;
                    if (ns - posins < forward)
                    {
                        posins = ns;
                        command++;
                    }
                    else
                    {
                        posins = posins - forward;
                        command++;
                    }
                }
                else if (ns > 0 && posins != ns) 
                {
                    if (ns - posins < forward)
                    {
                        posins = ns;
                        command++;
                    }
                    else
                    {
                        posins = posins + forward;
                        command++;
                    }
                }
                
            }
            Console.WriteLine(command);
        }
    }
}
0