結果
問題 | No.113 宝探し |
ユーザー | dai11 |
提出日時 | 2017-08-04 09:26:41 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 572 bytes |
コンパイル時間 | 1,327 ms |
コンパイル使用メモリ | 157,868 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 21:35:40 |
合計ジャッジ時間 | 1,986 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%s",S); | ~~~~~^~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main(int argc, char **argv) { char S[100]; //入力される文字列(N,E,W,S) int i; //ループカウンタ int counter1 = 0; //移動した値 int counter2 = 0; //移動した値 scanf("%s",S); for(i = 0;i < strlen(S);i++) { if('S' == S[i]) { counter1++; } else if('N' == S[i]) { counter1--; } else if('E' == S[i]) { counter2++; } else if('W' == S[i]) { counter2--; } } //printf("%0.5f\n",sqrt(counter)); printf("%f\n",hypot(counter1,counter2)); return 0; }