結果

問題 No.48 ロボットの操縦
ユーザー ooh_20
提出日時 2017-05-29 11:59:50
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 2,911 ms / 5,000 ms
コード長 2,000 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 106,652 KB
実行使用メモリ 17,792 KB
最終ジャッジ日時 2024-09-21 18:05:49
合計ジャッジ時間 5,160 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace No._48
{
    class Program
    {
        static void Main(string[] args)
        {
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());
            int L = int.Parse(Console.ReadLine());
            int count = 0;

            if (Y > 0)
            {
                while (Y > 0)
                {
                    Y -= L;
                    count++;
                }

                if (X > 0)
                {
                    count++;

                    while(X > 0)
                    {
                        X -= L;
                        count++;
                    }
                }
                else if (X < 0)
                {
                    count++;

                    while(X < 0)
                    {
                        X += L;
                        count++;
                    }
                }
            }
            else
            {
                if (X > 0)
                {
                    count++;

                    while (X > 0)
                    {
                        X -= L;
                        count++;
                    }
                }
                else if (X < 0)
                {
                    count++;

                    while (X < 0)
                    {
                        X += L;
                        count++;
                    }
                }
                else
                {
                    if (Y == 0)
                    {
                        Console.WriteLine(count);
                        return;
                    }

                    count++;
                }

                if (Y < 0)
                {
                    count++;

                    while (Y < 0)
                    {
                        Y += L;
                        count++;
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}
0