結果

問題 No.523 LED
ユーザー phsplsphspls
提出日時 2020-07-05 17:21:37
言語 Rust
(1.77.0)
結果
AC  
実行時間 99 ms / 2,000 ms
コード長 631 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 165,588 KB
実行使用メモリ 79,896 KB
最終ジャッジ日時 2023-10-23 21:32:20
合計ジャッジ時間 2,949 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 99 ms
79,896 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 0 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 19 ms
16,776 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 93 ms
79,896 KB
testcase_19 AC 32 ms
29,500 KB
testcase_20 AC 28 ms
26,468 KB
testcase_21 AC 67 ms
60,180 KB
testcase_22 AC 75 ms
67,368 KB
testcase_23 AC 76 ms
67,296 KB
testcase_24 AC 3 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

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