結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2019-04-14 17:42:30 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 810 bytes |
コンパイル時間 | 23,770 ms |
コンパイル使用メモリ | 378,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 22:03:27 |
合計ジャッジ時間 | 12,683 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
use std::io::stdin; /// エントリポイント fn main() { let input = read_lines(); println!("{}", treasure_hunt(input)); } /// 標準入力から文字列を取得します。 fn read_lines() -> String { let mut str1 = String::new(); stdin().read_line(&mut str1).unwrap(); str1 } fn treasure_hunt(direction: String) -> f64 { // 0:NS, 1:EW let mut dir_count = [0f64; 2]; for d in direction.trim().chars() { match d { 'N' => dir_count[0] += 1f64, 'S' => dir_count[0] -= 1f64, 'E' => dir_count[1] += 1f64, 'W' => dir_count[1] -= 1f64, _ => panic!(), } } // 南東(NE) let ne = dir_count[0].powf(2.0); // 北西(SW) let sw = dir_count[1].powf(2.0); (ne + sw).sqrt() }