結果

問題 No.2751 429-like Number
ユーザー maguroflymagurofly
提出日時 2024-05-10 21:38:10
言語 Rust
(1.77.0)
結果
AC  
実行時間 678 ms / 4,000 ms
コード長 658 bytes
コンパイル時間 23,307 ms
コンパイル使用メモリ 401,952 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-10 21:38:54
合計ジャッジ時間 21,479 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,812 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 13 ms
6,944 KB
testcase_08 AC 16 ms
6,940 KB
testcase_09 AC 15 ms
6,944 KB
testcase_10 AC 271 ms
6,940 KB
testcase_11 AC 678 ms
6,940 KB
testcase_12 AC 542 ms
6,940 KB
testcase_13 AC 34 ms
6,940 KB
testcase_14 AC 97 ms
6,940 KB
testcase_15 AC 14 ms
6,940 KB
testcase_16 AC 140 ms
6,944 KB
testcase_17 AC 179 ms
6,940 KB
testcase_18 AC 296 ms
6,940 KB
testcase_19 AC 283 ms
6,940 KB
testcase_20 AC 291 ms
6,940 KB
testcase_21 AC 261 ms
6,940 KB
testcase_22 AC 293 ms
6,940 KB
testcase_23 AC 286 ms
6,940 KB
testcase_24 AC 283 ms
6,940 KB
testcase_25 AC 287 ms
6,940 KB
testcase_26 AC 281 ms
6,940 KB
testcase_27 AC 288 ms
6,944 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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`

ソースコード

diff #

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" });
	}
}
0