AtCoder Beginner Contest 001

Submission #7466590

Source codeソースコード

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        m: i32
    }

    let vv = calc(m)

    println!("{0}", vv);
}

fn calc(m: i32) -> String {
    let vv = if m < 1000 {
        0
    } else if m <= 5000 {
        m * 10
    } else if m <= 30000 {
        m + 50000
    } else if m <= 70000 {
        (m - 30) / 5 + 80000
    } else { // m > 70000
        89000
    };
    format!("{:>02}", (vv / 1000));
}

#[test]
fn test() {
    assert_eq!("65", calc(15000));
    assert_eq!("89", calc(75000));
    assert_eq!("02", calc(200));
}

Submission

Task問題 B - 視程の通報
User nameユーザ名 kamokamokamone
Created time投稿日時
Language言語 Rust (1.15.1)
Status状態 CE
Score得点 -
Source lengthソースコード長 1978 Byte
File nameファイル名
Exec time実行時間 -
Memory usageメモリ使用量 -

Compiler messageコンパイルメッセージ

error: expected one of `.`, `;`, `?`, or an operator, found `println`
--> ./Main.rs:61:5
|
61 | println!("{0}", vv);
| ^^^^^^^

error: aborting due to previous error

Test case