結果

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

ソースコード

diff #

#include<iostream>
#include<cmath>
#include<string>
using namespace std;
int main(){
    int a=0;int b=0;
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='N'){
            a++;
        }else if(s[i]=='E'){
            b++;
        }else if(s[i]=='W'){
            b--;
        }else if(s[i]=='S'){
            a--;
        }
    }
    cout<<fixed<<sqrt(a*a+b*b)<<endl;
}
0