結果

問題 No.533 Mysterious Stairs
ユーザー uenokuuenoku
提出日時 2017-10-26 07:58:57
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 1,318 bytes
コンパイル時間 11,883 ms
コンパイル使用メモリ 406,916 KB
実行使用メモリ 56,704 KB
最終ジャッジ日時 2024-05-01 14:56:35
合計ジャッジ時間 15,046 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
56,528 KB
testcase_01 AC 66 ms
56,576 KB
testcase_02 AC 67 ms
56,516 KB
testcase_03 AC 68 ms
56,496 KB
testcase_04 AC 67 ms
56,484 KB
testcase_05 AC 67 ms
56,556 KB
testcase_06 AC 66 ms
56,576 KB
testcase_07 AC 67 ms
56,576 KB
testcase_08 AC 67 ms
56,580 KB
testcase_09 AC 68 ms
56,700 KB
testcase_10 AC 66 ms
56,704 KB
testcase_11 AC 67 ms
56,448 KB
testcase_12 AC 67 ms
56,380 KB
testcase_13 AC 69 ms
56,576 KB
testcase_14 AC 68 ms
56,576 KB
testcase_15 AC 68 ms
56,628 KB
testcase_16 AC 67 ms
56,508 KB
testcase_17 AC 66 ms
56,484 KB
testcase_18 AC 66 ms
56,448 KB
testcase_19 AC 68 ms
56,360 KB
testcase_20 AC 69 ms
56,576 KB
testcase_21 AC 71 ms
56,576 KB
testcase_22 AC 71 ms
56,580 KB
testcase_23 AC 79 ms
56,692 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{stdin, Read};
use std::str::FromStr;
#[allow(unused_imports)]
use std::{cmp, mem, process};
#[allow(unused_imports)]
use std::collections::{HashSet, BTreeMap, BTreeSet};

fn main() {
    let n: usize = read::<usize>();
    let mut dp = vec![vec![0; 4]; 1000005];
    dp[1][1] = 1;
    dp[2][2] = 1;
    dp[3][3] = 1;
    let modulo = 1000000007;
    for i in 1..n + 3 {
        for j in 1..4 {
            for k in 1..4 {
                if k != j {
                    dp[i + j][j] = (dp[i + j][j] + dp[i][k]) % modulo;
                }
            }
        }
    }
    println!("{}", (dp[n][1] + dp[n][2] + dp[n][3]) % modulo);
}


#[allow(dead_code)]
fn read_vec<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for _ in 0..n {
        let a = read::<T>();
        v.push(a);
    }
    v
}
#[allow(dead_code)]
fn read_str() -> Vec<char> {
    let s: String = read();
    s.chars().collect::<Vec<char>>()
}
#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let s = stdin
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(
        |_| panic!("Faild to parse {}", s),
    )
}
0