Browse Source

044 ok

master
Coin de Gamma 1 year ago
parent
commit
e12b8a76ce
  1. 31
      044/main.rs

31
044/main.rs

@ -0,0 +1,31 @@
use std::collections::HashSet;
fn main() {
let mut hs = HashSet::new();
for n in 1..10000 {
let pn = n * ( 3*n -1 ) / 2;
hs.insert(pn);
}
let mut D = 10000000;
for p in hs.iter() {
for q in hs.iter() {
if q <= p {
continue;
}
let s = *p + *q;
if !hs.contains(&s) {
continue;
}
let d = *q - *p;
if !hs.contains(&d) {
continue;
}
if d < D {
D = d;
}
}
}
println!("{}", D);
}
Loading…
Cancel
Save