結果
問題 | No.1730 GCD on Blackboard in yukicoder |
ユーザー |
|
提出日時 | 2022-10-16 17:47:13 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 1,233 ms / 2,000 ms |
コード長 | 1,030 bytes |
コンパイル時間 | 14,876 ms |
コンパイル使用メモリ | 379,420 KB |
実行使用メモリ | 14,704 KB |
最終ジャッジ日時 | 2024-06-27 12:36:47 |
合計ジャッジ時間 | 25,221 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 24 |
ソースコード
const LIMIT: usize = 1e6 as usize; 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 used_cnt = vec![0usize; LIMIT + 1]; for i in 0..n { for j in 1..=(a[i] as f64).sqrt().floor() as usize { if a[i] % j == 0 { let l = j; let r = a[i]/j; used_cnt[l] += 1; if l != r { used_cnt[r] += 1; } } } } let mut result = vec![0usize; n]; for i in (1..=LIMIT).rev() { if used_cnt[i] == 0 { continue; } let mut idx = n-used_cnt[i]; while idx < n && result[idx] == 0 { result[idx] = i; idx += 1; } } for &v in result.iter() { println!("{}", v); } }