結果
| 問題 |
No.510 二次漸化式
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-04-30 01:55:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,713 bytes |
| コンパイル時間 | 12,814 ms |
| コンパイル使用メモリ | 383,412 KB |
| 実行使用メモリ | 13,880 KB |
| 最終ジャッジ日時 | 2024-09-13 19:19:52 |
| 合計ジャッジ時間 | 33,724 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 20 TLE * 1 -- * 12 |
コンパイルメッセージ
warning: unnecessary parentheses around `for` iterator expression
--> src/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 {
|
ソースコード
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);
}
}