結果

問題 No.113 宝探し
ユーザー olphe
提出日時 2016-11-20 03:55:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 58,960 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 21:29:09
合計ジャッジ時間 1,162 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:38: warning: NULL used in arithmetic [-Wpointer-arith]
   11 |         for (int i = 0; letter[i] != NULL; i++) {
      |                                      ^~~~

ソースコード

diff #

#include "iostream"
#include "math.h"
using namespace std;

char letter[200];
int x, y;
double ans;

int main() {
	cin >> letter;
	for (int i = 0; letter[i] != NULL; i++) {
		if (letter[i] == 'N')y++;
		else if (letter[i] == 'S')y--;
		else if (letter[i] == 'W')x++;
		else x--;
	}
	ans = sqrt(float(x)*float(x) + float(y)*float(y));
	cout << ans << "\n";
	return 0;

}
0