結果

問題 No.113 宝探し
ユーザー TDTD
提出日時 2022-06-02 14:28:57
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 28 ms / 5,000 ms
コード長 1,101 bytes
コンパイル時間 1,275 ms
コンパイル使用メモリ 108,536 KB
実行使用メモリ 25,100 KB
最終ジャッジ日時 2023-10-21 01:07:03
合計ジャッジ時間 3,409 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
25,096 KB
testcase_01 AC 26 ms
25,096 KB
testcase_02 AC 27 ms
25,096 KB
testcase_03 AC 27 ms
25,100 KB
testcase_04 AC 26 ms
25,100 KB
testcase_05 AC 27 ms
25,032 KB
testcase_06 AC 26 ms
25,032 KB
testcase_07 AC 27 ms
25,100 KB
testcase_08 AC 26 ms
25,088 KB
testcase_09 AC 28 ms
25,020 KB
testcase_10 AC 28 ms
25,100 KB
testcase_11 AC 26 ms
25,100 KB
testcase_12 AC 27 ms
25,096 KB
testcase_13 AC 26 ms
25,032 KB
testcase_14 AC 26 ms
25,032 KB
testcase_15 AC 26 ms
25,096 KB
testcase_16 AC 26 ms
25,100 KB
testcase_17 AC 27 ms
25,032 KB
testcase_18 AC 27 ms
25,032 KB
testcase_19 AC 27 ms
25,100 KB
testcase_20 AC 27 ms
25,100 KB
testcase_21 AC 27 ms
25,100 KB
testcase_22 AC 27 ms
25,100 KB
testcase_23 AC 25 ms
24,176 KB
testcase_24 AC 27 ms
25,100 KB
testcase_25 AC 26 ms
25,100 KB
testcase_26 AC 26 ms
25,100 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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)
        {

            string s = Console.ReadLine();
            int[] b = new int[4];
            double c=0;
            double d = 0;
 
            double ans = 0;
            for(int i = 0; i <s.Length; i++)
            {
               string  a = s.Substring(i,1);
                if (a == "N")
                {
                    b[0]++;
                }else if (a == "E")
                {
                    b[1]++;
                }else if (a == "W")
                {
                    b[2]++;
                }else
                {
                    b[3]++;
                }
            }
            c = b[0] - b[3];
            d = b[2] - b[1];
            if (c < 0)
            {
                c *= -1;
            }
            if (d < 0)
            {
                d *= -1;
            }
            c=Math.Pow(c, 2);
            d = Math.Pow(d, 2);
            ans = Math.Sqrt(c + d) ;
            
            Console.WriteLine(ans);
            
        }
    }
}
0