https://atcoder.jp/contests/math-and-algorithm/tasks/math_and_algorithm_ab
Fibonacci数列ですね。
// Frog1 #![allow(non_snake_case)] fn read<T: std::str::FromStr>() -> T { let mut line = String::new(); std::io::stdin().read_line(&mut line).ok(); line.trim().parse().ok().unwrap() } fn f(N: usize) -> i32 { let mut dp = (0..N+1).map(|_| 1).collect::<Vec<i32>>(); for i in 2..N+1 { dp[i] = dp[i-1] + dp[i-2] } dp[N] } fn main() { let N: usize = read(); println!("{}", f(N)) }