|
|
@ -2,8 +2,6 @@ use std::fs::File; |
|
|
|
use std::io::{ self, BufRead, BufReader }; |
|
|
|
use std::io::{ self, BufRead, BufReader }; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const PS_SIZE: usize = 500usize; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn get_ps() -> Vec<u32> { |
|
|
|
fn get_ps() -> Vec<u32> { |
|
|
|
let file = File::open("primes.txt").unwrap(); |
|
|
|
let file = File::open("primes.txt").unwrap(); |
|
|
|
let lines = io::BufReader::new(file).lines(); |
|
|
|
let lines = io::BufReader::new(file).lines(); |
|
|
@ -11,11 +9,23 @@ fn get_ps() -> Vec<u32> { |
|
|
|
.collect(); |
|
|
|
.collect(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fn divs_num_test(n: u32) -> u32 { |
|
|
|
fn div_num(ps: &Vec<u32>, n: u32) -> u32 { |
|
|
|
|
|
|
|
fn max_div(m: u32, k: u32) -> u32 { |
|
|
|
let mut res = 0; |
|
|
|
let mut res = 0; |
|
|
|
for i in 1..n { |
|
|
|
let mut mm = m; |
|
|
|
if n % i == 0 { res += 1; } |
|
|
|
while mm % k == 0 { |
|
|
|
|
|
|
|
mm /= k; |
|
|
|
|
|
|
|
res += 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
res |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let mut res = 1; |
|
|
|
|
|
|
|
for p in ps { |
|
|
|
|
|
|
|
let md = max_div(n, *p) + 1; |
|
|
|
|
|
|
|
res *= md; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return res; |
|
|
|
return res; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -23,12 +33,12 @@ fn main() { |
|
|
|
let ps = get_ps(); |
|
|
|
let ps = get_ps(); |
|
|
|
let mut n = 1; |
|
|
|
let mut n = 1; |
|
|
|
let mut best_dn = 1; |
|
|
|
let mut best_dn = 1; |
|
|
|
for k in 2..50000 { |
|
|
|
for k in 2..80000 { |
|
|
|
n += k; |
|
|
|
n += k; |
|
|
|
let dn = 500; //500; //divs_num(n);
|
|
|
|
let dn = div_num(&ps, n); |
|
|
|
//if dn > best_dn {
|
|
|
|
if dn > best_dn { |
|
|
|
// best_dn = dn;
|
|
|
|
best_dn = dn; |
|
|
|
//println!("[{}]{}:{}",k, n, dn);
|
|
|
|
println!("[{}]{}:{}", k, n, dn); |
|
|
|
//}
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|