結果

問題 No.188 HAPPY DAY
ユーザー cm-kojimatcm-kojimat
提出日時 2020-07-09 16:16:58
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 1,369 bytes
コンパイル時間 2,082 ms
コンパイル使用メモリ 145,344 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-04-16 16:50:15
合計ジャッジ時間 807 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Input {}

fn read_input(_cin_lock: &mut StdinLock) -> Input {
    Input {}
}

fn solve(_input: Input) {
    let ans = (1..12 + 1)
        .map(|m| {
            let max_d = match m {
                2 => 28,
                4 | 6 | 9 | 11 => 30,
                _ => 31,
            };

            (1..max_d + 1)
                .map(|d| {
                    let x_sum = d
                        .to_string()
                        .chars()
                        .into_iter()
                        .map(|s| s.to_string().parse::<i64>().ok().unwrap())
                        .sum::<i64>();
                    if x_sum == m {
                        1
                    } else {
                        0
                    }
                })
                .sum::<i64>()
        })
        .sum::<i64>();

    println!("{}", ans)
}

fn _next_token<T: FromStr>(cin_lock: &mut StdinLock) -> T {
    cin_lock
        .by_ref()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>()
        .parse::<T>()
        .ok()
        .unwrap()
}

fn main() {
    let cin = stdin();
    let mut cin_lock = cin.lock();
    let input = read_input(&mut cin_lock);
    solve(input);
}
0