結果

問題 No.172 UFOを捕まえろ
ユーザー Wataru Maeda
提出日時 2018-10-03 21:32:48
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,248 bytes
コンパイル時間 771 ms
コンパイル使用メモリ 111,416 KB
実行使用メモリ 29,376 KB
最終ジャッジ日時 2024-10-12 10:29:24
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
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