結果

問題 No.113 宝探し
ユーザー h_noson
提出日時 2016-02-14 18:15:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 401 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 59,860 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 21:08:32
合計ジャッジ時間 1,286 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;

int main() {
    int x = 0, y = 0;
    string s;
    cin >> s;
    for (char c : s) {
        if (c == 'N')
            y++;
        else if (c == 'E')
            x++;
        else if (c == 'W')
            x--;
        else if (c == 'S')
            y--;
    }
    double ans = sqrt(x * x + y * y);
    cout << ans << endl;
    return 0;
}
0