結果
| 問題 |
No.2751 429-like Number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 21:38:10 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 755 ms / 4,000 ms |
| コード長 | 658 bytes |
| コンパイル時間 | 14,810 ms |
| コンパイル使用メモリ | 400,812 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-20 04:42:47 |
| 合計ジャッジ時間 | 21,272 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 22 |
コンパイルメッセージ
warning: variable `Q` should have a snake case name --> src/main.rs:22:3 | 22 | Q: usize, | ^ help: convert the identifier to snake case: `q` | = note: `#[warn(non_snake_case)]` on by default warning: variable `A` should have a snake case name --> src/main.rs:23:3 | 23 | A: [i64; Q], | ^ help: convert the identifier to snake case: `a`
ソースコード
use proconio::input;
fn solve(a: i64) -> bool {
let max_p = a.min((a as f64 * 2.0).cbrt().ceil() as i64);
let Some(p) = (2 ..= max_p).find(|&p| a % p == 0 ) else { return false };
let b = a / p;
let max_q = b.min((b as f64 * 2.0).sqrt().ceil() as i64);
let Some(q) = (2 ..= max_q).find(|&q| b % q == 0 ) else { return false };
let c = b / q;
if c <= 1 {
return false;
}
let max_r = (c - 1).min((c as f64 * 2.0).sqrt().ceil() as i64);
if let Some(_) = (2 ..= max_r).find(|&r| c % r == 0 ) {
return false;
}
true
}
fn main() {
input! {
Q: usize,
A: [i64; Q],
}
for a in A {
println!("{}", if solve(a) { "Yes" } else { "No" });
}
}