結果

問題 No.188 HAPPY DAY
ユーザー mtwtkmanmtwtkman
提出日時 2019-10-13 17:15:49
言語 Rust
(1.77.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 792 bytes
コンパイル時間 4,335 ms
コンパイル使用メモリ 135,328 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-22 07:16:19
合計ジャッジ時間 4,826 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: function `read_stdin` is never used
 --> Main.rs:3:4
  |
3 | fn read_stdin() -> Vec<String> {
  |    ^^^^^^^^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

ソースコード

diff #

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

fn read_stdin() -> Vec<String> {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).ok();
    buffer.trim().split('\n').map(|s| s.to_string()).collect()
}

fn main() {
    let days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    let result = (1..days.len() + 1).zip(days.iter()).fold(0, |sum, (i, day)| {
        sum + (1..*day + 1).fold(0, |acc, d| {
            if d >= 10 {
                let a = d / 10;
                let b = d % 10;
                if i == a + b {
                    acc + 1
                } else {
                    acc
                }
            } else if i == d {
                acc + 1
            } else {
                acc
            }
        })
    });
    println!("{}", result);
}
0