結果
問題 | No.1514 Squared Matching |
ユーザー | phspls |
提出日時 | 2022-11-03 16:44:26 |
言語 | Rust (1.77.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 787 bytes |
コンパイル時間 | 6,088 ms |
コンパイル使用メモリ | 140,296 KB |
実行使用メモリ | 445,948 KB |
最終ジャッジ日時 | 2023-09-25 01:19:54 |
合計ジャッジ時間 | 12,121 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
8,752 KB |
testcase_01 | TLE | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
ソースコード
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); }