fn main() { let mut v = input_vector_row::(5); v.reverse(); let mut fibo = vec![1, 1_usize]; for i in 0..100 { let buf = fibo[i] + fibo[i + 1]; fibo.push(buf); if buf > 1_000_000_000_000_000 { break; } } let mut ans = 0; let mut table = vec![]; let mut p = 0; for i in v { if table.len() == 1 && *table.last().unwrap() == 0 && i != 1 { table[0] += 1; } while fibo[p] != i { p += 1; if p == fibo.len() { break; } } if p == fibo.len() { break; } if table.len() == 0 || *table.last().unwrap() + 1 == p { table.push(p); } else { break; } p += 1; } println!("{}", table.len()); } pub mod input { use std::io; const SPLIT_DELIMITER: char = ' '; /// 空白で区切られた複数の値の読み込む。 /// # Example /// ```ignore /// use cp_template::*; /// /// let (a,b):(usize,usize); /// input!(a,b); /// ``` #[macro_export] #[allow(unused_macros)] macro_rules! inputm { ( $($x:expr ),*) => { { let temp_str = input_line_str(); let mut split_result_iter = temp_str.split_whitespace(); $( let buf_split_result = split_result_iter.next(); let buf_split_result = buf_split_result.unwrap(); ($x) = buf_split_result.parse().unwrap(); )* } }; } /// 文字列を一行読み込む /// # Example /// ```ignore /// use cp_template::*; /// /// let s = input_line_str(); /// ``` pub fn input_line_str() -> String { let mut s = String::new(); io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() } /// 指定した行数を読み込み、二次元配列に変換する。 /// # Examples /// ```ignore /// use cp_template::*; /// /// //10行読み込む。 /// let v = input_vector2d::(10); /// ``` pub fn input_vector2d(line: usize) -> Vec> where T: std::str::FromStr, { let mut v: Vec> = Vec::new(); for _ in 0..line { let vec_line = input_vector(); v.push(vec_line); } v } /// 一行読み込み、配列(Vec)に変換する。 /// # Examples /// ```ignore /// use cp_template::*; /// /// let v=input_vector::(); /// ``` #[allow(clippy::match_wild_err_arm)] pub fn input_vector() -> Vec where T: std::str::FromStr, { let mut v: Vec = Vec::new(); let s = input_line_str(); let split_result = s.split(SPLIT_DELIMITER); for z in split_result { let buf = match z.parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } /// 指定された行数を読み込む #[allow(clippy::match_wild_err_arm)] pub fn input_vector_row(n: usize) -> Vec where T: std::str::FromStr, { let mut v = Vec::with_capacity(n); for _ in 0..n { let buf = match input_line_str().parse() { Ok(r) => r, Err(_) => panic!("Parse Error",), }; v.push(buf); } v } /// StringをVecに変換するトレイト pub trait ToCharVec { fn to_charvec(&self) -> Vec; } impl ToCharVec for String { fn to_charvec(&self) -> Vec { self.to_string().chars().collect::>() } } } use input::*;