結果
問題 | No.1331 Moving Penguin |
ユーザー | Moss_Local |
提出日時 | 2021-01-09 12:23:53 |
言語 | Rust (1.77.0 + proconio) |
結果 |
AC
|
実行時間 | 208 ms / 1,500 ms |
コード長 | 5,414 bytes |
コンパイル時間 | 13,751 ms |
コンパイル使用メモリ | 378,788 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-07 15:03:34 |
合計ジャッジ時間 | 22,939 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,248 KB |
testcase_02 | AC | 1 ms
5,248 KB |
testcase_03 | AC | 1 ms
5,248 KB |
testcase_04 | AC | 174 ms
5,248 KB |
testcase_05 | AC | 171 ms
5,248 KB |
testcase_06 | AC | 171 ms
5,248 KB |
testcase_07 | AC | 172 ms
5,248 KB |
testcase_08 | AC | 171 ms
5,248 KB |
testcase_09 | AC | 175 ms
5,248 KB |
testcase_10 | AC | 171 ms
5,248 KB |
testcase_11 | AC | 173 ms
5,248 KB |
testcase_12 | AC | 172 ms
5,248 KB |
testcase_13 | AC | 170 ms
5,248 KB |
testcase_14 | AC | 174 ms
5,248 KB |
testcase_15 | AC | 173 ms
5,248 KB |
testcase_16 | AC | 171 ms
5,248 KB |
testcase_17 | AC | 171 ms
5,248 KB |
testcase_18 | AC | 174 ms
5,248 KB |
testcase_19 | AC | 174 ms
5,248 KB |
testcase_20 | AC | 174 ms
5,248 KB |
testcase_21 | AC | 174 ms
5,248 KB |
testcase_22 | AC | 173 ms
5,248 KB |
testcase_23 | AC | 169 ms
5,248 KB |
testcase_24 | AC | 171 ms
5,248 KB |
testcase_25 | AC | 166 ms
5,248 KB |
testcase_26 | AC | 171 ms
5,248 KB |
testcase_27 | AC | 175 ms
5,248 KB |
testcase_28 | AC | 172 ms
5,248 KB |
testcase_29 | AC | 172 ms
5,248 KB |
testcase_30 | AC | 36 ms
5,248 KB |
testcase_31 | AC | 73 ms
5,248 KB |
testcase_32 | AC | 30 ms
5,248 KB |
testcase_33 | AC | 52 ms
5,248 KB |
testcase_34 | AC | 97 ms
5,248 KB |
testcase_35 | AC | 194 ms
5,248 KB |
testcase_36 | AC | 195 ms
5,248 KB |
testcase_37 | AC | 191 ms
5,248 KB |
testcase_38 | AC | 38 ms
5,248 KB |
testcase_39 | AC | 163 ms
5,248 KB |
testcase_40 | AC | 62 ms
5,248 KB |
testcase_41 | AC | 168 ms
5,248 KB |
testcase_42 | AC | 195 ms
5,248 KB |
testcase_43 | AC | 195 ms
5,248 KB |
testcase_44 | AC | 195 ms
5,248 KB |
testcase_45 | AC | 208 ms
5,248 KB |
testcase_46 | AC | 207 ms
5,248 KB |
testcase_47 | AC | 207 ms
5,248 KB |
testcase_48 | AC | 169 ms
5,248 KB |
コンパイルメッセージ
warning: unnecessary parentheses around type --> src/main.rs:42:15 | 42 | fn readi() -> (i64) { | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 42 - fn readi() -> (i64) { 42 + fn readi() -> i64 { |
ソースコード
// -*- coding:utf-8-unix -*- #![allow(dead_code)] #![allow(unused_imports)] use std::cmp::Ordering::*; use std::collections::*; use std::convert::*; use std::convert::{From, Into}; use std::fmt::Debug; use std::fs::File; use std::io::prelude::*; use std::io::*; use std::marker::Copy; use std::mem::*; use std::ops::Bound::*; use std::ops::{Add, Mul, Neg, Sub}; use std::str; use std::vec; use std::{cmp, process::Output}; use std::{cmp::Ordering, env::consts::DLL_PREFIX}; const INF: i64 = 1223372036854775807; const MEM_SIZE: usize = 202020; const MOD: i64 = 1000000007; // const MOD: i64 = 998244353; use std::cmp::*; use std::collections::*; use std::io::stdin; use std::io::stdout; use std::io::Write; use btree_map::{Keys, Values}; // use str::Chars; #[allow(dead_code)] fn read<T: std::str::FromStr>() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } #[allow(dead_code)] fn readi() -> (i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); iter.next().unwrap().parse::<i64>().unwrap() } #[allow(dead_code)] fn read_vec<T: std::str::FromStr>() -> Vec<T> { read::<String>() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() } #[allow(dead_code)] fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> { (0..n).map(|_| read_vec()).collect() } #[allow(dead_code)] fn readii() -> (i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } fn readff() -> (f64, f64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<f64>().unwrap(), iter.next().unwrap().parse::<f64>().unwrap(), ) } #[allow(dead_code)] fn readiii() -> (i64, i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } #[allow(dead_code)] fn readuu() -> (usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } fn readcc() -> (char, char) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<char>().unwrap(), iter.next().unwrap().parse::<char>().unwrap(), ) } #[allow(dead_code)] fn readuuu() -> (usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } #[allow(dead_code)] fn readuuuu() -> (usize, usize, usize, usize) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<usize>().unwrap(), ) } fn readiiii() -> (i64, i64, i64, i64) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), iter.next().unwrap().parse::<i64>().unwrap(), ) } fn readin() -> (usize, char) { let mut str = String::new(); let _ = stdin().read_line(&mut str).unwrap(); let mut iter = str.split_whitespace(); ( iter.next().unwrap().parse::<usize>().unwrap(), iter.next().unwrap().parse::<char>().unwrap(), ) } fn solve() { let n: usize = read(); let vec: Vec<usize> = read_vec(); let mut dp = vec![0; n + 1]; dp[0] = 1; let m = (n as f64).sqrt() as usize; let mut sum = vec![vec![0 as usize; (m + 1) as usize]; (m + 1) as usize]; for i in 0..n { if i != 0 { if vec[i - 1] > 1 { dp[i] += dp[i - 1]; dp[i] %= MOD as usize; } } for j in 1..=m { dp[i] += sum[j][i % j]; dp[i] %= MOD as usize; } if vec[i] <= m { sum[vec[i]][i % vec[i]] += dp[i]; sum[vec[i]][i % vec[i]] %= MOD as usize; } else { let mut p = i + vec[i]; while p < n { dp[p] += dp[i]; dp[p] %= MOD as usize; p += vec[i]; } } } // println!("{:?}", dp); println!("{:?}", dp[n - 1]); return; } fn main() { solve() }