結果

問題 No.172 UFOを捕まえろ
ユーザー Wataru MaedaWataru Maeda
提出日時 2018-10-03 21:32:48
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 103,552 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-04-20 14:51:42
合計ジャッジ時間 1,881 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
19,072 KB
testcase_01 AC 22 ms
19,200 KB
testcase_02 AC 23 ms
19,200 KB
testcase_03 AC 20 ms
18,944 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 22 ms
18,944 KB
testcase_07 AC 22 ms
19,072 KB
testcase_08 WA -
testcase_09 AC 21 ms
19,072 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 21 ms
18,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace Problem172
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Console.ReadLine().Split(' ');
            var x = int.Parse(arr[0]);
            var y = int.Parse(arr[1]);
            var r = int.Parse(arr[2]);

            var shieta = getRadian(0, 0, x, y);
            var z = getDistance(0, 0, x, y);
            z += r;

            double ans = 0;
            if (x == 0 || y == 0)
            {
                ans = Math.Sqrt(2) * z;
            }
            else
            {
                var p = getCoord(shieta, z);
                ans = Math.Abs(p[0] + p[1]);
            }
            Console.WriteLine(Math.Ceiling(ans));
            Console.ReadKey();
        }

        static double getDistance(double x, double y, double x2, double y2)
            => Math.Sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));

        static double getRadian(double x, double y, double x2, double y2)
            => Math.Atan2(y2 - y, x2 - x);

        static double[] getCoord(double radian, double distance)
        {
            var y2 = Math.Sin(radian) * distance;
            var x2 = Math.Cos(radian) * distance;
            return new[] { x2, y2 };
        }
    }
}
0