結果

問題 No.523 LED
ユーザー phspls
提出日時 2020-07-05 17:21:37
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 12,029 ms
コンパイル使用メモリ 393,836 KB
実行使用メモリ 79,960 KB
最終ジャッジ日時 2024-09-22 15:01:40
合計ジャッジ時間 13,870 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).ok();
    let n: usize = n.trim().parse().unwrap();

    const DIVISOR: usize = 1_000_000_007;
    let mut dp: Vec<usize> = vec![0; n+1];
    dp[1] = 1;
    for i in 2..=n {
        //1回1回押す -> (2 * (i-1) + 1) C 2
        //2連打 -> (2 * (i-1) + 1)
        dp[i] = (2 * (i-1) + 1) * dp[i-1];
        dp[i] %= DIVISOR;
        let mut temp: usize = (2 * (i-1) + 1) * 2 * (i-1) / 2;
        temp %= DIVISOR;
        temp *= dp[i-1];
        temp %= DIVISOR;
        dp[i] += temp;
        dp[i] %= DIVISOR;
    }
    println!("{}", dp[n]);
}
0