結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2019-10-03 15:46:56 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 773 bytes |
コンパイル時間 | 13,152 ms |
コンパイル使用メモリ | 376,904 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 22:12:43 |
合計ジャッジ時間 | 14,266 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
fn getline() -> String { let mut __ret = String::new(); std::io::stdin().read_line(&mut __ret).ok(); return __ret; } fn main() { let input = getline(); let s = input.trim(); let mut x: i32 = 0; let mut y: i32 = 0; for direction in s.chars().into_iter() { if direction == 'N' { y += 1; } else if direction == 'S' { y -= 1; } else if direction == 'E' { x += 1; } else if direction == 'W' { x -= 1; } } if x < 0 { x *= -1; } if y < 0 { y *= -1; } let sum_of_squares: f64 = x.pow(2) as f64 + y.pow(2) as f64; let distance_to_treasure: f64 = sum_of_squares.sqrt(); println!("{}", distance_to_treasure); }