結果
問題 | No.979 Longest Divisor Sequence |
ユーザー |
|
提出日時 | 2023-01-21 16:39:40 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 441 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 14,660 ms |
コンパイル使用メモリ | 400,540 KB |
実行使用メモリ | 8,960 KB |
最終ジャッジ日時 | 2024-06-24 00:07:23 |
合計ジャッジ時間 | 16,796 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:5:9 | 5 | let n: usize = n.trim().parse().unwrap(); | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
fn main() { let mut n = String::new(); std::io::stdin().read_line(&mut n).ok(); let n: usize = n.trim().parse().unwrap(); let mut a = String::new(); std::io::stdin().read_line(&mut a).ok(); let a: Vec<usize> = a.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let mut maxvals = vec![0usize; 300001]; for &v in a.iter() { maxvals[v] = maxvals[v].max(1); if v == 1 { continue; } for i in 1..=(v as f64).sqrt().floor() as usize { if v % i == 0 { maxvals[v] = maxvals[v].max(maxvals[i]+1); if i > 1 { maxvals[v] = maxvals[v].max(maxvals[v/i]+1); } } } } println!("{}", maxvals.iter().max().unwrap()); }