結果
| 問題 |
No.1730 GCD on Blackboard in yukicoder
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-16 17:39:58 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,065 bytes |
| コンパイル時間 | 15,030 ms |
| コンパイル使用メモリ | 401,560 KB |
| 実行使用メモリ | 23,436 KB |
| 最終ジャッジ日時 | 2024-06-27 12:32:01 |
| 合計ジャッジ時間 | 22,068 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 2 |
| other | TLE * 1 -- * 23 |
ソースコード
use std::collections::HashSet;
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 {
let mut used = HashSet::new();
for j in 1..=(a[i] as f64).sqrt().floor() as usize {
if a[i] % j == 0 {
used.insert(j);
used.insert(a[i]/j);
}
}
for &v in used.iter() {
used_cnt[v] += 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);
}
}