結果

問題 No.48 ロボットの操縦
ユーザー bayashiko_r
提出日時 2018-11-03 17:07:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 24 ms / 5,000 ms
コード長 792 bytes
コンパイル時間 2,217 ms
コンパイル使用メモリ 109,776 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-11-20 19:20:34
合計ジャッジ時間 2,754 ms
ジャッジサーバーID
(参考情報)
judge1 / 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;

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 ans = 0;

        //X方向に必要となる回数
        if (X != 0) {
            ans += 1 + (Math.Abs(X) - 1) / L;
        }
        
        //Y方向に必要となる回数
        if (Y != 0) {
            ans += 1 + (Math.Abs(Y) - 1) / L;
        }
        
        //エリアによって場合分け
        if (Y < 0) {
            ans += 2;
        } else if (X == 0) {
            //何も足さない
        } else {
            ans += 1;
        }
        //出力
        Console.WriteLine(ans);
    }
}
0