結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2018-03-15 18:17:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 858 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 31,488 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 21:50:15 |
合計ジャッジ時間 | 1,432 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%s",S); | ~~~~~^~~~~~~~
ソースコード
#include <stdio.h> #include <math.h> int main(){ //input char S[100+1]; scanf("%s",S); //calculation int pos[2] = {0,0}; for (int i = 0;i < 100+1;i++){ if (S[i] != '\0'){ switch (S[i]) { case 'N': pos[0] += 0; pos[1] += 1; break; case 'S': pos[0] += 0; pos[1] += -1; break; case 'E': pos[0] += 1; pos[1] += 0; break; case 'W': pos[0] += -1; pos[1] += 0; break; } }else{ break; } } //output printf("%f\n",sqrt(pos[0]*pos[0]+pos[1]*pos[1])); return 0; }