結果

問題 No.510 二次漸化式
ユーザー packet0packet0
提出日時 2017-04-30 01:55:10
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,713 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 154,092 KB
実行使用メモリ 10,612 KB
最終ジャッジ日時 2023-10-11 20:28:38
合計ジャッジ時間 22,875 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
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 2,333 ms
5,716 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
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:25:14
   |
25 |     for i in (2..q+2) {
   |              ^      ^
   |
   = note: `#[warn(unused_parens)]` on by default
help: remove these parentheses
   |
25 -     for i in (2..q+2) {
25 +     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];
    a[0] = 1;
    b[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();
        match list[0].as_bytes()[0] as char {
            'x' => {
                x[list[1].parse::<usize>().unwrap()] = list[2].parse().unwrap();
                ai = 0;
            },
            'y' => {
                y[list[1].parse::<usize>().unwrap()] = list[2].parse().unwrap();
                ai = 0;
                bi = 0;
            },
            'a' => {
                let v = list[1].parse().unwrap();
                while bi < v {
                    let next = bi + 1;
                    b[next] = (b[bi] * y[bi] + 1) % DIV;
                    bi = next;
                }
                while ai < v {
                    let next = ai + 1;
                    a[next] = (b[ai] * b[ai] * x[ai] + a[ai]) % DIV;
                    ai = next;
                }
                println!("{:?}", a[v]);
            },
            _ => panic!(),
        }
        // println!("x{:?}", x);
        // println!("y{:?}", y);
        // println!("a{:?}", a);
        // println!("b{:?}", b);
    }
}
0