結果

問題 No.423 ハムスター語初級(数詞)
ユーザー machikoxmachikox
提出日時 2019-04-26 11:52:39
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 941 bytes
コンパイル時間 13,302 ms
コンパイル使用メモリ 394,600 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 05:01:47
合計ジャッジ時間 14,165 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 AC 1 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, BufRead};

fn get_lines() -> Vec<String> {
    let stdin = io::stdin();
    let lines: Vec<String> = stdin.lock().lines().map(|l| l.unwrap()).collect();
    return lines;
}

fn main(){
    let s = &get_lines()[0];
    let mut ans: u32 = 1;
    let mut i = s.chars().skip(4);
    let mut x = i.nth(3);
    loop {
        let c = match x {
            Some(x) => x,
            None => {
                let s = format!("{:b}", ans * 2);
                for c in s.chars() {
                    if c == '1' {
                        print!("hamu");
                    } else {
                        print!("ham");
                    }
                }
                println!("");
                return;
            }
        };
        if c == 'u' {
            ans = ans << 1;
            ans += 1;
            x = i.nth(3);
        } else {
            ans = ans << 1;
            x = i.nth(2);
        }
    }
}
0