結果

問題 No.510 二次漸化式
ユーザー packet0packet0
提出日時 2017-04-30 02:25:01
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,750 bytes
コンパイル時間 4,946 ms
コンパイル使用メモリ 150,084 KB
実行使用メモリ 6,496 KB
最終ジャッジ日時 2023-10-11 20:29:06
合計ジャッジ時間 22,380 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 65 ms
4,352 KB
testcase_03 AC 65 ms
4,348 KB
testcase_04 AC 49 ms
4,352 KB
testcase_05 AC 50 ms
4,352 KB
testcase_06 AC 325 ms
4,352 KB
testcase_07 AC 321 ms
4,352 KB
testcase_08 AC 479 ms
4,348 KB
testcase_09 AC 477 ms
4,348 KB
testcase_10 AC 18 ms
4,352 KB
testcase_11 AC 19 ms
4,352 KB
testcase_12 AC 18 ms
4,348 KB
testcase_13 AC 18 ms
4,348 KB
testcase_14 AC 19 ms
4,348 KB
testcase_15 AC 19 ms
4,348 KB
testcase_16 AC 2,371 ms
6,440 KB
testcase_17 AC 1,561 ms
6,416 KB
testcase_18 AC 1,569 ms
6,428 KB
testcase_19 AC 1,606 ms
6,420 KB
testcase_20 AC 2,376 ms
6,236 KB
testcase_21 AC 2,372 ms
6,412 KB
testcase_22 AC 2,377 ms
6,496 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unnecessary parentheses around `for` iterator expression
  --> Main.rs:27:14
   |
27 |     for i in (2..q+2) {
   |              ^      ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
27 -     for i in (2..q+2) {
27 +     for i in 2..q+2 {
   |

warning: 1 warning emitted

ソースコード

diff #

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

const DIV: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let lines: Vec<String> = stdin.lock().lines().map(|x| x.unwrap()).collect();

    let n0: usize = lines[0].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[1].parse().unwrap();
    for i in (2..q+2) {
        let list: Vec<&str> = lines[i].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 = 0;
            },
            'y' => {
                y[v] = list[2].parse().unwrap();
                ai = 0;
                bi = 0;
            },
            '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