結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
|
提出日時 | 2023-01-08 15:32:33 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 896 bytes |
コンパイル時間 | 15,205 ms |
コンパイル使用メモリ | 375,604 KB |
実行使用メモリ | 5,760 KB |
最終ジャッジ日時 | 2024-12-15 18:32:36 |
合計ジャッジ時間 | 17,198 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 37 WA * 9 |
コンパイルメッセージ
warning: unused variable: `n` --> src/main.rs:6:9 | 6 | let n = nmp[0]; | ^ help: if this is intentional, prefix it with an underscore: `_n` | = note: `#[warn(unused_variables)]` on by default
ソースコード
fn main() { let mut nmp = String::new(); std::io::stdin().read_line(&mut nmp).ok(); let nmp: Vec<usize> = nmp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let n = nmp[0]; let m = nmp[1]; let p = nmp[2]; 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 maxval = *a.iter().max().unwrap(); if maxval >= m { println!("1"); return; } if a.iter().filter(|&&v| v % p > 0).count() == 0 { println!("-1"); return; } let basemax= *a.iter().filter(|&&v| v % p > 0).max().unwrap(); if basemax == 1 { println!("-1"); return; } let mut cnt = 1; let mut x = maxval; while x < m { x *= basemax; cnt += 1; } println!("{}", cnt); }