結果

問題 No.188 HAPPY DAY
ユーザー m0ntBL4Ncm0ntBL4Nc
提出日時 2019-10-12 08:56:10
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,122 bytes
コンパイル時間 7,532 ms
コンパイル使用メモリ 126,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-18 06:11:50
合計ジャッジ時間 1,431 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: variable does not need to be mutable
 --> Main.rs:2:9
  |
2 |     let mut month_max = 12;
  |         ----^^^^^^^^^
  |         |
  |         help: remove this `mut`
  |
  = note: `#[warn(unused_mut)]` on by default

warning: variable does not need to be mutable
 --> Main.rs:3:9
  |
3 |     let mut date_left_max = 3;
  |         ----^^^^^^^^^^^^^
  |         |
  |         help: remove this `mut`

warning: variable does not need to be mutable
 --> Main.rs:4:9
  |
4 |     let mut date_right_max = 9;
  |         ----^^^^^^^^^^^^^^
  |         |
  |         help: remove this `mut`

warning: 3 warnings emitted

ソースコード

diff #

fn main() {
    let mut month_max = 12;
    let mut date_left_max = 3;
    let mut date_right_max = 9;

    let mut happy_day_count = 0;

    for month in 1..month_max+1 {
        for date_left in 0..date_left_max+1 {
            for date_right in 0..date_right_max+1 {
                // 0日はあり得ない
                if date_left == 0 && date_right == 0 {
                    continue;
                }

                // 2月は28日まで
                if month == 2 && (date_left*10 + date_right) > 28 {
                    break;
                }

                // 4, 6, 9, 11は30日まで
                if (month == 4 || month == 6 || month == 9 || month == 11) && (date_left*10 + date_right) > 30 {
                    break;
                }

                // 31日より後の日付はあり得ない
                if date_left == 3 && date_right > 1 {
                    break;
                }

                if month == (date_left * 10 + date_right) {
                    happy_day_count += 1;
                }
            }
        }
    }

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