結果

問題 No.954 Result
ユーザー manta1130manta1130
提出日時 2020-09-27 19:54:33
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 3,725 bytes
コンパイル時間 1,123 ms
コンパイル使用メモリ 153,036 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-13 02:13:51
合計ジャッジ時間 3,420 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,384 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,384 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,384 KB
testcase_20 AC 1 ms
4,384 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,384 KB
testcase_25 AC 1 ms
4,384 KB
testcase_26 AC 1 ms
4,384 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 1 ms
4,384 KB
testcase_30 WA -
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 1 ms
4,384 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `ans`
  --> Main.rs:13:13
   |
13 |     let mut ans = 0;
   |             ^^^ help: if this is intentional, prefix it with an underscore: `_ans`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: variable does not need to be mutable
  --> Main.rs:13:9
   |
13 |     let mut ans = 0;
   |         ----^^^
   |         |
   |         help: remove this `mut`
   |
   = note: `#[warn(unused_mut)]` on by default

warning: 2 warnings emitted

ソースコード

diff #

fn main() {
    let mut v = input_vector_row::<usize>(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 {
        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::<usize>(10);
    /// ```
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = 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::<usize>();
    /// ```
    #[allow(clippy::match_wild_err_arm)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = 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<T>(n: usize) -> Vec<T>
    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<char>に変換するトレイト
    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}
use input::*;
0