結果

問題 No.113 宝探し
ユーザー Ysmr_Ry
提出日時 2015-01-04 22:12:26
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 361 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 31,104 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 20:38:35
合計ジャッジ時間 916 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |         scanf( "%s", S );
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cstring>
#include<cmath>
#define rep(i,a) for(int i=0;i<(a);++i)

char S[101];

int main()
{
	scanf( "%s", S );
	
	int x = 0, y = 0;
	rep( i, strlen(S) )
	{
		if( S[i] == 'N' )
			++y;
		else if( S[i] == 'E' )
			++x;
		else if( S[i] == 'W' )
			--x;
		else if( S[i] == 'S' )
			--y;
	}

	printf( "%f\n", sqrt(x*x+y*y) );

	return 0;
}
0