結果
| 問題 |
No.1514 Squared Matching
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-03 16:44:26 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 787 bytes |
| コンパイル時間 | 16,621 ms |
| コンパイル使用メモリ | 392,256 KB |
| 実行使用メモリ | 448,656 KB |
| 最終ジャッジ日時 | 2024-07-18 01:28:44 |
| 合計ジャッジ時間 | 22,295 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 TLE * 13 |
ソースコード
fn get_factors(n: usize) -> Vec<usize> {
let mut flgs = vec![true; n+1];
flgs[0] = false;
flgs[1] = false;
let mut factors = (0..=n).collect::<Vec<_>>();
for i in 2..=n {
if !flgs[i] { continue; }
let modval = i*i;
for j in 1..=n/i {
flgs[i*j] = false;
while factors[i*j] % modval == 0 {
factors[i*j] /= modval;
}
}
}
factors
}
fn main() {
let mut n = String::new();
std::io::stdin().read_line(&mut n).ok();
let n: usize = n.trim().parse().unwrap();
let factors = get_factors(n);
let mut result = 0;
for i in 1..=n {
let limit = n / factors[i];
result += (limit as f64).sqrt().floor() as usize;
}
println!("{}", result);
}