結果

問題 No.510 二次漸化式
ユーザー packet0packet0
提出日時 2017-04-30 02:47:42
言語 Rust
(1.77.0 + proconio)
結果
WA  
実行時間 -
コード長 1,847 bytes
コンパイル時間 12,691 ms
コンパイル使用メモリ 394,068 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-09-13 19:21:43
合計ジャッジ時間 36,960 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 182 ms
6,940 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1,029 ms
6,940 KB
testcase_17 AC 805 ms
6,940 KB
testcase_18 AC 842 ms
6,940 KB
testcase_19 AC 830 ms
6,944 KB
testcase_20 AC 995 ms
6,940 KB
testcase_21 AC 1,001 ms
6,944 KB
testcase_22 AC 1,024 ms
6,940 KB
testcase_23 AC 2,068 ms
6,944 KB
testcase_24 AC 2,042 ms
6,944 KB
testcase_25 AC 1,999 ms
6,944 KB
testcase_26 AC 2,033 ms
6,940 KB
testcase_27 AC 1,970 ms
6,940 KB
testcase_28 AC 1,651 ms
6,940 KB
testcase_29 AC 1,674 ms
6,940 KB
testcase_30 AC 1,610 ms
6,940 KB
testcase_31 AC 8 ms
6,944 KB
testcase_32 AC 8 ms
6,940 KB
testcase_33 AC 8 ms
6,944 KB
testcase_34 AC 34 ms
6,940 KB
testcase_35 AC 34 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `q`
  --> src/main.rs:27:9
   |
27 |     let q: usize = lines.next().unwrap().unwrap().parse().unwrap();
   |         ^ help: if this is intentional, prefix it with an underscore: `_q`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

use std::io::{self, BufRead};
use std::cmp;

const DIV: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let n0: usize = lines.next().unwrap().unwrap().parse().unwrap();
    let n1 = n0 + 1;
    let mut x = vec![0; n1];
    let mut y = vec![0; n1];
    let mut a = vec![0; n1];
    let mut b = vec![0; n1];
    let mut b2 = vec![0; n1];
    a[0] = 1;
    b[0] = 1;
    b2[0] = 1;
    let mut ai = 0;
    let mut bi = 0;
    // println!("x{:?}", x);
    // println!("y{:?}", y);
    // println!("a{:?}", a);
    // println!("b{:?}", b);

    let q: usize = lines.next().unwrap().unwrap().parse().unwrap();

    for line in lines {
        let line2 = line.unwrap();
        let list: Vec<&str> = line2.split_whitespace().collect();
        let v = list[1].parse::<usize>().unwrap();
        match list[0].as_bytes()[0] as char {
            'x' => {
                x[v] = list[2].parse().unwrap();
                ai = cmp::min(ai,v-1);
            },
            'y' => {
                y[v] = list[2].parse().unwrap();
                ai = cmp::min(ai,v-1);
                bi = cmp::min(bi,v-1);
            },
            'a' => {
                while bi < v {
                    let next = bi + 1;
                    b[next] = b[bi] * y[bi] % DIV + 1;
                    b2[next] = b[next] * b[next] % DIV;
                    bi = next;
                }
                while ai < v {
                    let next = ai + 1;
                    a[next] = b2[ai] * x[ai] % DIV + a[ai] % DIV;
                    ai = next;
                }
                println!("{}", a[v] % DIV);
            },
            _ => panic!(),
        }
        // println!("x{:?}", x);
        // println!("y{:?}", y);
        // println!("a{:?}", a);
        // println!("b{:?}", b);
    }
}
0