結果

問題 No.188 HAPPY DAY
ユーザー mottodoramottodora
提出日時 2016-10-15 00:33:31
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 644 bytes
コンパイル時間 1,843 ms
コンパイル使用メモリ 120,288 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-29 22:20:58
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

fn check(month:i32, day:i32) -> i32 {
    let x = day % 10 + day / 10;
    match x {
        a if a == month => return 1,
        _               => return 0,
    }
}

fn counthappyday(month:i32, day:i32) -> i32 {
    let mut count = 0;
    for i in 1..day+1 {
        count += check(month, i)
    }
    return count
}

fn happyday() -> i32 {
    let mut count = 0;

    for i in 1..13 {
        match i {
            2 => count += counthappyday(i, 28),
            4 | 6 | 9 | 11 => count += counthappyday(i, 30),
            _ => count += counthappyday(i, 31),
        }
    }
    return count
}

fn main() {
    println!("{}", happyday());
}
0