結果

問題 No.48 ロボットの操縦
ユーザー TDTD
提出日時 2022-05-27 09:16:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,801 bytes
コンパイル時間 980 ms
コンパイル使用メモリ 109,540 KB
実行使用メモリ 27,808 KB
最終ジャッジ日時 2024-09-20 15:11:21
合計ジャッジ時間 2,618 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    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)//y==-
            {
                if (x < 0)
                {
                    count++;
                    x *= -1;
                    count = Kxy(count, x, l);
                    count++;
                    y *= -1;
                    count = Kxy(count, y, l);
                }
                else
                {
                    count = Kxy(count, x, l);
                    count++;
                    y *= -1;
                    count = Kxy(count, y, l);
                }
                if (y == 0)
                {
                    Console.WriteLine(count);
                }
            }
            else//y==+
            {
                count = Kxy(count, y, l);
                if (x == 0)
                {
                    Console.WriteLine(count);
                }
                if (x < 0)//x -
                {
                    count++;
                    x *= -1;
                   count= Kxy(count, x, l);
                    Console.WriteLine(count);
                }
                else if (x > 0)
                {
                    count = Kxy(count, x, l);
                        Console.WriteLine(count);
                    
                }
            }
            static int Kxy(int count,int x,int l)
            {
                count += x / l;
                if (x % l != 0)
                {
                    count += x % l;
                }
                return count;
            }
        }
    }
}
0