結果
問題 |
No.1330 Multiply or Divide
|
ユーザー |
|
提出日時 | 2021-01-15 15:16:39 |
言語 | Rust (1.83.0 + proconio) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,518 bytes |
コンパイル時間 | 11,938 ms |
コンパイル使用メモリ | 379,732 KB |
実行使用メモリ | 6,144 KB |
最終ジャッジ日時 | 2024-11-26 01:52:47 |
合計ジャッジ時間 | 15,113 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 38 WA * 8 |
ソースコード
#[allow(dead_code)] mod scanner { use std; use std::io::Read; use std::str::FromStr; use std::str::SplitWhitespace; pub struct Scanner<'a> { it: SplitWhitespace<'a>, } impl<'a> Scanner<'a> { pub fn new(s: &'a String) -> Scanner<'a> { Scanner { it: s.split_whitespace(), } } pub fn next<T: FromStr>(&mut self) -> T { match self.it.next().unwrap().parse::<T>() { Ok(v) => v, _ => panic!("Scanner error"), } } pub fn next_chars(&mut self) -> Vec<char> { self.next::<String>().chars().collect() } pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> { (0..len).map(|_| self.next()).collect() } } pub fn read_string() -> String { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).unwrap(); s } } fn main() { let sc = scanner::read_string(); let mut sc = scanner::Scanner::new(&sc); let n: usize = sc.next(); let m: usize = sc.next(); let p: usize = sc.next(); let mut a = sc.next_vec::<usize>(n); for i in 0..n { while a[i] % p == 0 { a[i] /= p; } } a.sort(); a.reverse(); let ans = if a[0] == 1 { -1 } else { let mut b = 0; let mut x = 1; while m >= x { x *= a[0]; b += 1; } b }; println!("{}", ans); }