結果
| 問題 |
No.113 宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-12-01 23:07:17 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 359 bytes |
| コンパイル時間 | 126 ms |
| コンパイル使用メモリ | 24,064 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-26 03:11:55 |
| 合計ジャッジ時間 | 979 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:9:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%s",s);
| ^~~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void){
double ns=0,ew=0;
int i,l;
char s[128];
scanf("%s",s);
l = strlen(s);
for(i = 0;i < l;i++){
if(s[i] == 'N'){ns = ns + 1;}
if(s[i] == 'S'){ns = ns - 1;}
if(s[i] == 'E'){ew = ew + 1;}
if(s[i] == 'W'){ew = ew - 1;}
}
ns = sqrt(ns*ns+ew*ew);
printf("%.20lf",ns);
return 0;
}