Coin de Gamma 5 months ago
parent
commit
11b75c6e60
  1. 16
      045/main.rs

16
045/main.rs

@ -0,0 +1,16 @@
use std::collections::HashSet;
fn main() {
let mut ps = HashSet::new();
let mut hs = HashSet::new();
let N = 500000u64;
for n in 1..N { hs.insert(n*(2*n-1)); }
for n in 1..N { ps.insert(n*(3*n -1)/2 ); }
for n in 286u64..N {
let tn = n * (n+1)/2;
if !hs.contains(&tn) { continue; }
if !ps.contains(&tn) { continue; }
println!("{}", tn);
break;
}
}
Loading…
Cancel
Save