結果
| 問題 | 
                            No.1514 Squared Matching
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-11-03 16:50:02 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2,741 ms / 4,000 ms | 
| コード長 | 819 bytes | 
| コンパイル時間 | 10,702 ms | 
| コンパイル使用メモリ | 401,568 KB | 
| 実行使用メモリ | 441,728 KB | 
| 最終ジャッジ日時 | 2024-07-18 01:33:38 | 
| 合計ジャッジ時間 | 56,198 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 26 | 
ソースコード
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 as f64).sqrt().ceil() as usize {
        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);
}